ITeye博客

springboot map<String,MyObject> config application.yml

e_e · 2019-01-25 23:34 · springboot · 企业架构 · Markdown

参考官网:https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html

章节:  24.8.3 Merging Complex Types

application.yml

element-datasource:
  config:
    service1:
      url:
      method:
      content-type:
    service2:
      url:
      method:
      content-type:

 

 

@Component
@Configuration
@ConfigurationProperties("element-datasource")
@Data
public class ElementDatasourceConfig {

    private final Map<String , ExternalDatasourceProperties> config = new HashMap<>();

@Data
public static class ExternalDatasourceProperties {
        private String url;
        private String method;
        private String contentType;
}

}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。