参考官网: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; } }
相关推荐
Map<String, Object> config = new HashMap<>(); config.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092"); config.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class); ...
Map<String, Object> props = new HashMap<>(); props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);...
Map<String, Object> props = new HashMap<>(); props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092"); props.put(ConsumerConfig.GROUP_ID_CONFIG, "my-consumer-group"); props.put...
Map<String, Object> configMap = GetYamlUtil.getYamlConfig("application.yml"); int port = (int) configMap.get("server.port"); String appName = (String) configMap.get("spring.application.name"); ``` ...
Map<String, Object> props = new HashMap<>(); props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); props.put(ConsumerConfig.GROUP_ID_CONFIG, groupId); props.put(ConsumerConfig.KEY_...
Map<String, Object> config = new HashMap<>(); config.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092"); config.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class); ...
Map<String, RedisCacheConfiguration> cacheConfigs = new HashMap<>(); // example: 'myCache'缓存,1小时过期 cacheConfigs.put("myCache", config.entryTtl(Duration.ofHours(1))); cacheManager....
Map<String, Object> config = new HashMap<>(); config.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092"); Collection<NewTopic> topics = Arrays.asList(new NewTopic("my-topic", 3, ...
Map<String, Object> customProps = new HashMap<>(); customProps.put("my.custom.property", "customValue"); sources.addLast(new MapPropertySource("customProperties", customProps)); } } ``` 在上述...
Map<String, Object> jsonMap = new HashMap<>(); jsonMap.put("user", "kimchy"); jsonMap.put("postDate", new Date()); jsonMap.put("message", "trying out Elasticsearch"); IndexRequest indexRequest = ...
Map<String, String> properties = new HashMap<>(); properties.put("myName", "lizo"); MyPropertySource myPropertySource = new MyPropertySource("myPropertySource", properties); return ...
List<Map<String, Object>> result = jdbcTemplate.queryForList(sql); // 处理查询结果 } ``` 4. **Spring Boot的简化配置** 如果使用Spring Boot,配置变得更简单,因为Spring Boot默认集成了DataSource和...
Map<String, Object> props = new HashMap<>(); props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092"); props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);...