I'm trying to use a custom-spring-boot-starter with a Configuration dependent on the presence of properties as a dependecy in my spring-boot-project. The starter's configuration is something like this:
@Configuration
@ConditionalOnProperty( {"vcap.services.my-user-provided-service.credentials.git.password"})
public class MyConfig {
@Bean
public MyBean createBean() {
[...]
}
}
everything works fine in the local environment when I pass the property "vcap.services.my-user-provided-service.credentials.git.password" to the startup command.
However when I deploy the whole thing to cloudfoundry it doesn't create MyBean and subsequently the startup fails because an @Autowire on the Bean is failing. The log says that MyBean was not created because the property vcap.services.my-user-provided-service.credentials.git.password
is missing.
I defined the variable in a cloudfoundry user provided service my-user-provided-service
and bound it to the app and in the webconsole of cloudfoundry it appears in the env settings of the app as expected.
When I add the variables directly to the app (e.g. via the manifest) it works, however I don't want to thave the credentials there.
It seems like the user provided service's variables are not (yet?) available in the properties during the context startup and therefore not found. Are they picked up after other property sources? Do I maybe have to use a @AutoConfigureAfter
with some Bean of spring-cloud? I tried it with @AutoConfigureAfter(CloudFoundryVcapEnvironmentPostProcessor.class)
but that didnt help.
Any help is greatly appreciated.