Spring Boot: Multiple similar ConfigurationProperties with different Prefixes

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;

}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)