问题
I'm looking for a solution in spring boot where I can maintain same root key in multiple files and load it to a POJO.
application-profile-1.yml
active:
configuration:
- name: abc
....... (1000 lines in config)
application-profile-2.yml
active:
configuration:
- name: xyz
....... (900 lines in config)
application-profile-3.yml
active:
configuration:
- name: abc
....... (700 lines in config)
application.yml
spring.profiles.include: profile-1,profile-2,profile-3
@ConfigurationProperties(prefix = "active")
public class ActiveData {
private List<Configuration> channels = null;
}
After autowiring when I try to access configuration I see null.
Service {
@Autowired
private ActiveData activeData;
serviceMethod() {
activeData.configuration(); --> is coming as null
}
}
来源:https://stackoverflow.com/questions/64610099/load-multiple-yaml-file-with-same-root-key-in-spring-boot