@ConfigurationProperties,将 POJO绑定到指定的配置文件属性中
如下
@Component
@Data
@Configuration
@ConfigurationProperties(prefix = "chain-config")
public class ChainConfigProperties {
private List<ChainLinkVO> chains;
private String name;
private String code;
}
@Data
public class ChainLinkVO{
private String code;
private Map<Integer,String> maps;
private Map<String,String> mapStr;
}
chain-config:
chains:
- {code: default,maps:{'1':'connectChain','2':'loadFileChain','3':'formatChain','4':'sendChain','5':'archiveChain'}}
- {code: 1150,maps:{'1':'connectChain','2':'loadFileChain','3':'formatChain'}}
- {code: 1180,maps:{'1':'formatChain','2':'sendChain'}}