Reputation: 38842
I've added the following to my Gradle project to load Spring's AWS Secret Manager features:
plugins {
id 'org.springframework.boot' version '3.4.3'
id 'io.spring.dependency-management' version '1.1.6'
}
ext {
springCloudAwsVersion = '3.2.0'
}
dependencies {
...
implementation platform("io.awspring.cloud:spring-cloud-aws-dependencies:${springCloudAwsVersion}")
implementation 'io.awspring.cloud:spring-cloud-aws-starter-secrets-manager'
}
However, it doesn't work. I've tracked it down to the autoconfigure not loading because of a missing Bean org.springframework.cloud.context.refresh.ContextRefresher
. However, that is provided by yet another dependency org.springframework.cloud:spring-cloud-context
as evidenced by this in my logs:
SecretsManagerReloadAutoConfiguration:
Did not match:
- @ConditionalOnClass did not find required class 'org.springframework.cloud.context.refresh.ContextRefresher' (OnClassCondition)
That class is inside spring-cloud-context as far as I can see, but no where in the documentation.
I tried adding
implementation 'io.awspring.cloud:spring-cloud-aws-starter'
But that didn't change anything. I'm tempted to just try this, but again since it's not in the docs I'm not sure if this is a good idea.
implementation 'org.springframework.cloud:spring-cloud-context'
So what is the relationship between org.springframework.cloud
and io.awspring.cloud
? It seems from reading the docs they are competing feature sets. io.awspring.cloud
seems much more targeted to AWS support where org.springframework.cloud
supports AWS but also other cloud providers and wants to be a meta-cloud framework. So why is there this dependency between them?! Of all the tutorials out there no one discusses any of this. So how do I fix this?
Upvotes: 0
Views: 40
Reputation: 38842
Ok so this one was a tricky problem. And of course it's always the things you don't post that matter. The first problem was that I was looking at the wrong auto config. SecretsManagerReloadAutoConfiguration
wasn't being loaded and it was because of the missing spring cloud dependency, but I don't need that in order to use secrets manager. SecretsManagerAutoConfiguration
WAS being loaded and until I turned on enough logging that was the only evidence that things were setup correctly from a dependency standpoint.
At this point my question is off the rails so it's hard to answer from what I gave. I'm working on porting a Spring based app to Spring Boot, and so my profile specific config files used a different naming convention than Spring Boot's preferred method. And it was in these files that I had configured spring.import.config
property. Well spring.config.import
property is ignored when it is not in application.properties
or application-${profile}.properties
. Once I moved it to the application.properties
Spring Boot started trying to load the secrets!
After I renamed by special profile files to use the application-${profile}.properties
convention I could then put spring.config.import
property there, and Spring Boot would honor that.
Upvotes: 0