I\'m using Spring Boot and have two very similar services which I\'d like to configure in my application.yml
.
The configuration looks roughly like this:
I achieved almost same thing that you trying. first, register each properties beans.
@Bean
@ConfigurationProperties(prefix = "serviceA")
public ServiceProperties serviceAProperties() {
return new ServiceProperties ();
}
@Bean
@ConfigurationProperties(prefix = "serviceB")
public ServiceProperties serviceBProperties() {
return new ServiceProperties ();
}
and at service(or someplace where will use properties) put a @Qualifier and specified which property would be auto wired .
public class ServiceA {
@Autowired
@Qualifier("serviceAProperties")
private ServiceProperties serviceAProperties;
}