当此错误消息出现在 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.