Suppose I have the following third party class
@ConfigurationProperties(prefix = "third.party")
public class ThirdParty {
String value;
}
Now I'd like to create two separate beans automatically from the config without using setters.
Desired config:
some:
third:
party:
value: some-third-party-value
another:
third:
party:
value: another-third-party-value
I'd like to achieve something along the lines of:
@Configuration
@ConfigurationProperties
class ApplicationConfig {
@Bean(name = "someThirdParty")
@ConfigurationProperties(prefix="some")
public ThirdParty someThirdParty() {
return new ThirdParty();
}
@Bean(name = "anotherThirdParty")
@ConfigurationProperties(prefix="another")
public ThirdParty anotherThirdParty() {
return new ThirdParty();
}
}
Is this possible? Or should I find another way?
Note:
The code above would work with a class that does not have the @ConfigurationProperties
annotation present. Now they seem to 'clash' but as it's a class from a third-party lib I cannot edit the annotation