升级到Edgware.SR3时,没有类型为RsaProperties的合格Bean

时间:2018-06-27 18:29:40

标签: java spring spring-cloud spring-cloud-config

我正在尝试从Spring Cloud Edgware.SR2更新到Edgware.SR3。当我构建Spring Cloud Config Server时,ApplicationTests中的默认contextLoads测试失败,并显示以下错误:

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)}

我怀疑这是this change in Spring Cloud Commons的结果。我的encrypt.rsa文件中有bootstrap.yml个配置,该文件正在Edgware.SR2中运行,我尝试将compile( "org.springframework.security:spring-security-rsa" )添加到build.gradle中。

对于Spring Boot 1.5.14和Spring Cloud Edgware.SR3(Spring Cloud Config 1.4.3 and Spring Cloud Commons 1.3.3),只有测试失败。如果我注释掉测试,然后构建然后运行,它将成功启动并解密我的配置。如果我转到start.spring.io创建一个新的Spring Cloud Config项目,请添加我的application.yml,我的bootstrap.yml并包含spring-security-rsa,测试将失败,并且由于以下原因导致服务无法启动上面的错误。

  1. 为了使默认测试通过使用RSA加密数据的带有Spring Cloud Config的Spring Boot 1.5.14和Spring Cloud Edgware.SR3,我需要进行哪些更改?
  2. 我要怎么做才能通过Spring Boot 2.0.3和Spring Cloud Finchley通过测试和运行服务?

1 个答案:

答案 0 :(得分:0)

正如Spencer Gibb显示的here一样,问题在于,如果指定了encrypt.keyStore.location,那么就需要encrypt.keyStore.password(源代码here)。 encrypt.keyStore.location应该移到要通过bootstrap.yml中的配置文件指定的位置,这样测试不需要encrypt.keyStore.password