将应用程序加载到PCF时遇到问题

时间:2017-12-18 03:38:22

标签: pcf

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

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

1 个答案:

答案 0 :(得分: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.
相关问题