【问题标题】:No qualifying bean of type RsaProperties when upgrading to Edgware.SR3升级到 Edgware.SR3 时没有 RsaProperties 类型的合格 bean
【发布时间】:2018-06-27 18:29:40
【问题描述】:

我正在尝试从 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 的结果。我的bootstrap.yml 文件中有encrypt.rsa 配置,该文件在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. 为了让默认测试通过 Spring Boot 1.5.14 和 Spring Cloud Edgware.SR3 以及使用 RSA 加密数据的 Spring Cloud Config,我需要进行哪些更改?
  2. 我需要做些什么才能让测试通过并使用 Spring Boot 2.0.3 和 Spring Cloud Finchley 运行服务?

【问题讨论】:

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


    【解决方案1】:

    正如 Spencer Gibb 显示的 here,问题是当指定 encrypt.keyStore.location 时,需要 encrypt.keyStore.password(源代码 here)。 encrypt.keyStore.location 应移动到通过 bootstrap.yml 中的配置文件指定,以便测试不需要 encrypt.keyStore.password

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-07-12
      • 2019-01-21
      • 1970-01-01
      • 1970-01-01
      • 2022-01-14
      • 2019-04-27
      • 2020-06-18
      • 2020-06-10
      相关资源
      最近更新 更多