我正在尝试使用本地云弹簧连接器在本地环境中测试我的应用程序,然后才能将其部署到基于 CF 的云环境中。从春天链接
我遵循该过程并在项目资源目录中创建了名为 spring-cloud-bootstrap.properties 的属性文件。它有以下内容
spring.cloud.properties 文件:C:\Users\IBM_ADMIN\git\ServiceXchange5\ServiceXchange\spring-cloud.properties
我在上面给出的路径中有文件 spring-cloud.properties。
从spring configuaration bean我有以下
@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);
}
现在这个 DataSource 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 中、资源中等)
这里有什么帮助吗?