0

我尝试使用本地云弹簧连接器在本地环境中测试我的应用程序,然后才能将其部署到基于CF的云环境。从春天链接尝试使用本地弹簧云连接器时发现没有合适的云连接器/ local_configuration_connector

http://cloud.spring.io/spring-cloud-connectors/spring-cloud-connectors.html#_local_configuration_connector

我跟着过程和创建的属性与项目资源目录名称spring-cloud-bootstrap.properties文件。它具有以下内容

spring.cloud.propertiesFile:C:\用户\ IBM_ADMIN \ git的\ ServiceXchange5 \ ServiceXchange \ spring-cloud.properties

我确实有路径的文件spring-cloud.properties上面给出。

从春天configuaration豆,我有以下

@EnableWebMvc 
@Configuration 
@EnableAspectJAutoProxy 
public class CloudServiceConfig extends AbstractCloudConfig { 

@Bean 
public DataSource getDataSource() throws AppException { 

org.springframework.cloud.service.PooledServiceConnectorConfig.PoolConfig poolConfig = new PoolConfig(50, 100, 3000); 
org.springframework.cloud.service.relational.DataSourceConfig dbConfig = new DataSourceConfig(poolConfig, null); 
return connectionFactory().dataSource(SX_DB_USED, dbConfig); 

} 

现在这个数据源bean是在各种其他地方注射。有了属性文件,我预计将创建用于本地配置的云连接器Bean,并且我应该可以使用相同的方式为DataSource添加更多配置以实现连接池。

但是,当我访问应用程序似乎本地配置连接器本身它没有激活。

Initialization of bean failed; nested exception is org.springframework.cloud.CloudException: No suitable cloud connector found 
[ERROR ] SRVE0271E: Uncaught init() exception created by servlet [appServlet] in application [ServiceXchange]: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cloudServiceConfig' defined in file [C:\Users\IBM_ADMIN\git\ServiceXchange5\ServiceXchange\target\classes\com\hcl\service\config\CloudServiceConfig.class]: Initialization of bean failed; nested exception is org.springframework.cloud.CloudException: No suitable cloud connector found 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) 
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) 
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) 
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) 
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) 
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772) 
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839) 
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) 
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444) 
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326) 
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107) 
at com.ibm.ws.webcontainer.webapp.WebApp.notifyServletContextCreated(WebApp.java:2388) 
at [internal classes] 
Caused by: org.springframework.cloud.CloudException: No suitable cloud connector found 
at org.springframework.cloud.CloudFactory.getCloud(CloudFactory.java:55) 
at org.springframework.cloud.config.java.AbstractCloudConfig.setBeanFactory(AbstractCloudConfig.java:85) 
at com.hcl.service.config.CloudServiceConfig$$EnhancerBySpringCGLIB$$9529c032.CGLIB$setBeanFactory$54(<generated>) 
at com.hcl.service.config.CloudServiceConfig$$EnhancerBySpringCGLIB$$9529c032$$FastClassBySpringCGLIB$$6c6301dd.invoke(<generated>) 
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) 
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanFactoryAwareMethodInterceptor.intercept(ConfigurationClassEnhancer.java:277) 
at com.hcl.service.config.CloudServiceConfig$$EnhancerBySpringCGLIB$$9529c032.setBeanFactory(<generated>) 
at org.springframework.context.annotation.ConfigurationClassPostProcessor$EnhancedConfigurationBeanPostProcessor.postProcessPropertyValues(ConfigurationClassPostProcessor.java:480) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) 
... 13 more 

我不知道为什么本地云连接器未激活。根据链接它应该检测到属性文件后。

注:我试图把属性文件在不同的位置一样(直属应用程序根目录,在WEB-INF/lib目录,在资源等)

任何帮助吗?

+0

只是为了从最简单的可能问题开始 - 你能分享你的依赖列表来验证你的项目中包含了所有必需的jar文件吗? –

+0

@Scott这里有POM条目 org.springframework.cloud 弹簧云localconfig连接器 1.2.3.RELEASE org.springframework.cloud 弹簧云朵弹簧服务连接器 1.2.3。RELEASE

+0

我也尝试添加云代工连接器(虽然我不认为它需要本地配置),但同样的错误。从春天我使用4.2.6版本 –

回答

0

您是否使用maven shade插件打包您的应用程序?如果是这样,请确保安装了<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>

据我分析,当这是缺少的Cloud-Foundry连接器覆盖/覆盖本地连接器的ServiceLoaders。

所有这些当然只有当你试图运行你的本地构建的包。直接从IDE(在我的情况下IntelliJ)它一直工作。