问题
I'm trying to update from Spring Cloud Edgware.SR2 to Edgware.SR3. When I build the Spring Cloud Config Server the default contextLoads test in ApplicationTests fails with the following error:
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'encryptionBootstrapConfiguration': Unsatisfied dependency expressed through field 'encryptor'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.cloud.config.server.config.DefaultTextEncryptorConfiguration': Unsatisfied dependency expressed through field 'locator'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.cloud.config.server.config.EncryptionAutoConfiguration$KeyStoreConfiguration': Unsatisfied dependency expressed through field 'rsaProperties'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.cloud.bootstrap.encrypt.RsaProperties' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
I suspect that this is the result of this change in Spring Cloud Commons. I have encrypt.rsa
configuration in my bootstrap.yml
file which is working in Edgware.SR2 and I've tried adding compile( "org.springframework.security:spring-security-rsa" )
to build.gradle
.
With Spring Boot 1.5.14 and Spring Cloud Edgware.SR3 (Spring Cloud Config 1.4.3 and Spring Cloud Commons 1.3.3), it is only the test that fails. If I comment out the test, build and then run, it starts successfully and decrypts my configuration. If I go to start.spring.io to create a new Spring Cloud Config project, added my application.yml
, my bootstrap.yml
and include spring-security-rsa
the test fails and the service fails to start due to the above error.
- What change would I need to make in order to for the default test to pass on Spring Boot 1.5.14 and Spring Cloud Edgware.SR3 with Spring Cloud Config that uses RSA encrypted data?
- What would I need to do to get both the test to pass and the service to run with Spring Boot 2.0.3 and Spring Cloud Finchley?
回答1:
As Spencer Gibb showed here, the problem was that when encrypt.keyStore.location
is specified then encrypt.keyStore.password
is required (source code here). encrypt.keyStore.location
should be moved to be specified through profiles in bootstrap.yml
, so that encrypt.keyStore.password
isn't required for the test.
来源:https://stackoverflow.com/questions/51069326/no-qualifying-bean-of-type-rsaproperties-when-upgrading-to-edgware-sr3