springboot map config application.yml

阅读更多

参考官网: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, ExternalDatasourceProperties> config = new HashMap<>();

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

}

你可能感兴趣的:(springboot map config application.yml)