`

springboot map<String,MyObject> 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<String , ExternalDatasourceProperties> config = new HashMap<>();

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

}
分享到:
评论

相关推荐

    SpringBoot-2.0.4整合kafka

    Map&lt;String, Object&gt; config = new HashMap&lt;&gt;(); config.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092"); config.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class); ...

    springboot 基于spring-kafka动态创建kafka消费者

    Map&lt;String, Object&gt; props = new HashMap&lt;&gt;(); props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);...

    springboot集成kafka

    Map&lt;String, Object&gt; props = new HashMap&lt;&gt;(); props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092"); props.put(ConsumerConfig.GROUP_ID_CONFIG, "my-consumer-group"); props.put...

    GetYamlUtil.rar

    Map&lt;String, Object&gt; configMap = GetYamlUtil.getYamlConfig("application.yml"); int port = (int) configMap.get("server.port"); String appName = (String) configMap.get("spring.application.name"); ``` ...

    springboot kafka整合

    Map&lt;String, Object&gt; props = new HashMap&lt;&gt;(); props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); props.put(ConsumerConfig.GROUP_ID_CONFIG, groupId); props.put(ConsumerConfig.KEY_...

    kafka操作详解.docx

    Map&lt;String, Object&gt; config = new HashMap&lt;&gt;(); config.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092"); config.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class); ...

    redis与springcache集成

    Map&lt;String, RedisCacheConfiguration&gt; cacheConfigs = new HashMap&lt;&gt;(); // example: 'myCache'缓存,1小时过期 cacheConfigs.put("myCache", config.entryTtl(Duration.ofHours(1))); cacheManager....

    spring boot操作kafka例子

    Map&lt;String, Object&gt; config = new HashMap&lt;&gt;(); config.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092"); Collection&lt;NewTopic&gt; topics = Arrays.asList(new NewTopic("my-topic", 3, ...

    springboot配置含动态配置

    Map&lt;String, Object&gt; customProps = new HashMap&lt;&gt;(); customProps.put("my.custom.property", "customValue"); sources.addLast(new MapPropertySource("customProperties", customProps)); } } ``` 在上述...

    Elasticsearch基础教程.pdf

    Map&lt;String, Object&gt; jsonMap = new HashMap&lt;&gt;(); jsonMap.put("user", "kimchy"); jsonMap.put("postDate", new Date()); jsonMap.put("message", "trying out Elasticsearch"); IndexRequest indexRequest = ...

    spring boot自定义配置源操作步骤

    Map&lt;String, String&gt; properties = new HashMap&lt;&gt;(); properties.put("myName", "lizo"); MyPropertySource myPropertySource = new MyPropertySource("myPropertySource", properties); return ...

    spring无web.xml的jdbctemplate配置

    List&lt;Map&lt;String, Object&gt;&gt; result = jdbcTemplate.queryForList(sql); // 处理查询结果 } ``` 4. **Spring Boot的简化配置** 如果使用Spring Boot,配置变得更简单,因为Spring Boot默认集成了DataSource和...

    KafkaConsumer:Spring Boot Kafka消费者

    Map&lt;String, Object&gt; props = new HashMap&lt;&gt;(); props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092"); props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);...

Global site tag (gtag.js) - Google Analytics