-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extend and override 'ConfigClientProperties' #724
Comments
I supposed you could try adding |
I cannot use I can try that with @primary. But maybe there will be a way, like in the basic spring boot autoconfigure, to provide an ordering of BootstrapConfigurations and to let other override the ConfigurationProperties of spring cloud or like in this case spring cloud config. -- I tried @primary, but that does not work, because first the if there would be a mechanism like |
I think the section on providing a custom rest template should give you some idea http://cloud.spring.io/spring-cloud-static/Dalston.SR1/#custom-rest-template |
OK I tried some configurations but nothing works. FirstIf I expose the First your
and that makes sense. Here my configuration: @Bean
@Primary
CoffeeNetConfigClientProperties configClientProperties() {
CoffeeNetConfigClientProperties clientProperties = new
CoffeeNetConfigClientProperties(environment);
clientProperties.setEnabled(false);
return clientProperties;
}
@Bean
CoffeeNetClientCredentialsResourceDetailsProperties
coffeeNetClientCredentialsResourceDetailsProperties() {
return new CoffeeNetClientCredentialsResourceDetailsProperties();
}
@Bean
ConfigServicePropertySourceLocator configServicePropertySource() {
final ConfigClientProperties properties =
coffeeNetConfigClientProperties();
final CoffeeNetClientCredentialsResourceDetailsProperties
resourceDetailsProperties =
coffeeNetClientCredentialsResourceDetailsProperties();
ConfigServicePropertySourceLocator locator = new
ConfigServicePropertySourceLocator(properties);
locator.setRestTemplate(new
OAuth2RestTemplate(resourceDetailsProperties));
return locator;
} Next trySo I tried to prefix the
Here is my code: @Bean
@Primary
CoffeeNetConfigClientProperties coffeeNetConfigClientProperties() {
CoffeeNetConfigClientProperties clientProperties = new CoffeeNetConfigClientProperties(environment);
clientProperties.setEnabled(false);
return clientProperties;
}
@Bean
CoffeeNetClientCredentialsResourceDetailsProperties coffeeNetClientCredentialsResourceDetailsProperties() {
return new CoffeeNetClientCredentialsResourceDetailsProperties();
}
@Bean
ConfigServicePropertySourceLocator configServicePropertySource() {
final ConfigClientProperties properties = coffeeNetConfigClientProperties();
final CoffeeNetClientCredentialsResourceDetailsProperties resourceDetailsProperties =
coffeeNetClientCredentialsResourceDetailsProperties();
ConfigServicePropertySourceLocator locator = new ConfigServicePropertySourceLocator(properties);
locator.setRestTemplate(new OAuth2RestTemplate(resourceDetailsProperties));
return locator;
} Next tryThen I thought maybe I have to completely override all @Bean
@Primary
ConfigClientProperties configClientProperties() {
CoffeeNetConfigClientProperties clientProperties = new CoffeeNetConfigClientProperties(environment);
clientProperties.setEnabled(false);
return clientProperties;
} to expose the bean with the class @Bean
ConfigServicePropertySourceLocator configServicePropertySource() {
final ConfigClientProperties properties = configClientProperties();
final CoffeeNetClientCredentialsResourceDetailsProperties resourceDetailsProperties =
coffeeNetClientCredentialsResourceDetailsProperties();
ConfigServicePropertySourceLocator locator = new ConfigServicePropertySourceLocator(properties);
locator.setRestTemplate(new OAuth2RestTemplate(resourceDetailsProperties));
return locator;
} and now maybe you can tell me what I am doing wrong :) Without any a Fyi the injection of the OAuth2RestTemplate is working well via locator.setRestTemplate(new OAuth2RestTemplate(resourceDetailsProperties)); The code is located there: |
and? :) do you have some information for me? |
After some thought, I dont' think we want to support users trying to subclass and replace our configuration properties. |
Hmm, what if someone wants their own custom behavior to be part of the PropertySourceBootstrapConfiguration. Not everyone wants to use .properties or .yml. This is a similar issue that has been discussed around people wanting to load .json files in the Spring Cloud Config as in here: spring-projects/spring-boot#4027 (comment) |
|
Hey,
I want to provide my own 'ConfigClientProperties' with special default values integrated in my
own autoconfiguration. I can not provide my own property because there is no
@ConditionalOnMissingBean in the
ConfigServiceBootstrapConfiguration
class.Also I would need something like
@AutoConfigureBefore
in the bootstrap phase, or?Is there a way to provide my own bean of the
ConfigClientProperties
? I also want to expose the configuration on another conf. path and not under "spring.cloud.config.*"The text was updated successfully, but these errors were encountered: