升级到 Edgware.SR3 时没有 RsaProperties 类型的合格 bean [英] No qualifying bean of type RsaProperties when upgrading to Edgware.SR3
问题描述
我正在尝试从 Spring Cloud Edgware.SR2 更新到 Edgware.SR3.当我构建 Spring Cloud Config Server 时,ApplicationTests 中的默认 contextLoads 测试失败并显示以下错误:
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)}
我怀疑这是 Spring Cloud 中 这一变化的结果共享.我的 bootstrap.yml
文件中有 encrypt.rsa
配置,该文件在 Edgware.SR2 中工作,我尝试添加 compile("org.springframework.security:spring-security-rsa" )
到 build.gradle
.
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
.
使用 Spring Boot 1.5.14 和 Spring Cloud Edgware.SR3 (Spring Cloud Config 1.4.3 和 Spring Cloud Commons 1.3.3),只有测试失败.如果我注释掉测试,构建然后运行,它会成功启动并解密我的配置.如果我去 start.spring.io 创建一个新的 Spring Cloud Config 项目,添加我的 application.yml
、我的 bootstrap.yml
并包含 spring-security-rsa
由于上述错误,测试失败,服务启动失败.
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.
- 为了让默认测试通过使用 RSA 加密数据的 Spring Cloud Config 和 Spring Boot 1.5.14 和 Spring Cloud Edgware.SR3,我需要进行哪些更改?
- 我需要怎么做才能通过测试并使服务与 Spring Boot 2.0.3 和 Spring Cloud Finchley 一起运行?
推荐答案
正如 Spencer Gibb 所展示的 这里,问题是当 encrypt.keyStore.location
被指定时,encrypt.keyStore.password
是必需的(源代码 此处).encrypt.keyStore.location
应该移动到通过 bootstrap.yml
中的配置文件指定,这样 encrypt.keyStore.password
不是必需的用于测试.
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.
这篇关于升级到 Edgware.SR3 时没有 RsaProperties 类型的合格 bean的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!