jpa使用bean加载配置项

yml配置文件

com:
  aa:
    bb:
      cc:
        types:
          - name: type1
            title: 单位1
          - name: type12
            title: 单位2
          - name: type13
            title: 类型3
          - name: type14
            title:类型4

配置类

@ConfigurationProperties(prefix = "com.aa.bb.cc")
@Component
@Data
public class StatisticProperties  {

    private List types;

}


@Data
public class StatisticType {
    private String name;    //类型
    private String title;   //显示
}

使用

    @Resource
    private StatisticProperties statisticProperties;

 

你可能感兴趣的:(jpa使用bean加载配置项)