0

'ConfigServiceBootstrapConfiguration'中的Bean方法'configServicePropertySource'未加载,因为@ConditionalOnProperty(spring.cloud.config.enabled)在属性'spring.cloud.config.enabled'中找到不同的值2017-12-17T14:40:46.20 + 0530 [APP /PROC/WEB/0] io.pivotal.spring.cloud.service.config.ConfigClientOAuth2BootstrapConfiguration$ConfigClientOAuth2Configurer 中的 OUT 字段定位器需要找不到类型为“org.springframework.cloud.config.client.ConfigServicePropertySourceLocator”的 bean。

- 当我尝试将其加载到 PCF 中时,我收到了上述消息。但是在本地运行时,它按预期工作。

4

1 回答 1

0

当此错误消息出现在 Spring Boot 2.01 / Pivotal Cloud Foundry / Groovy / Gradle 环境中时,我注意到的另一件事是,当我删除对正在开发的基于 Spring Boot 的模块的依赖时,问题就消失了。

修复方法是更改​​导入模块的 build.gradle,以便依赖项是 compileOnly() 而不是 compile()。

像这样,

    compileOnly('org.springframework.boot:spring-boot-starter')
    compileOnly('org.springframework.boot:spring-boot-starter-amqp')
    compileOnly('org.springframework.cloud:spring-cloud-config-server')
    compileOnly('org.springframework.boot:spring-boot-configuration-processor')
    testCompile('org.springframework.boot:spring-boot-starter')
    testCompile('org.springframework.boot:spring-boot-starter-amqp')
    testCompile('org.springframework.cloud:spring-cloud-config-server')

代替,

    compile('org.springframework.boot:spring-boot-starter')
    compile('org.springframework.boot:spring-boot-starter-amqp')
    compile('org.springframework.cloud:spring-cloud-config-server')
    compile('org.springframework.boot:spring-boot-configuration-processor')

我的理论是环境中 Spring Boot 框架的多个实例之间存在冲突,这删除了其中一个,但我不确定这是否正确。

这是来自我的环境的完整错误消息:

***************************
APPLICATION FAILED TO START
Description:
Parameter 1 of constructor in io.pivotal.spring.cloud.service.config.ConfigClientOAuth2BootstrapConfiguration$ConfigClientOAuth2Configurer required a bean of type 'org.springframework.cloud.config.client.ConfigServicePropertySourceLocator' that could not be found.
- Bean method 'configServicePropertySource' in 'ConfigServiceBootstrapConfiguration' not loaded because @ConditionalOnProperty (spring.cloud.config.enabled) found different value in property 'spring.cloud.config.enabled'
Action:
Consider revisiting the conditions above or defining a bean of type 'org.springframework.cloud.config.client.ConfigServicePropertySourceLocator' in your configuration.

在对 Spring Boot 模块的不同组合进行故障排除时,我也看到了这个错误,我相信它的原因是一样的:

***************************
APPLICATION FAILED TO START
Description:
Parameter 0 of constructor in io.pivotal.spring.cloud.service.config.VaultTokenRenewalAutoConfiguration required a bean of type 'io.pivotal.spring.cloud.service.config.ConfigClientOAuth2ResourceDetails' that could not be found.
[OUT] Action:
[OUT] Consider defining a bean of type 'io.pivotal.spring.cloud.service.config.ConfigClientOAuth2ResourceDetails' in your configuration.
于 2018-05-24T13:39:32.427 回答