繁体   English   中英

没有找到合适的ServiceConnectorCreator错误 - Spring cloud / CloudFoundry

[英]No suitable ServiceConnectorCreator found error - Spring cloud/CloudFoundry

所有,

当我尝试推送到IBM Bluemix / CloudFoundry时,我有一个Spring启动应用程序,它给了我一个错误。

这是一个spring boot应用程序,使用spring cloud并尝试连接到关系数据库服务(sqldb,它是DB2的云版本)服务。

我可以在没有spring cloud的情况下连接,我在我的属性文件中明确指定了vcap_services中的db凭据。 但是我试图避免使用spring cloud抽象,但得到下面提到的错误。

我的期望是spring boot / cloud应该识别我绑定到app的test-sqldb服务并动态创建数据源。 相反,当我执行cf push时,我得到下面给出的错误。

是否公平地假设spring boot / cloud对将为我编排数据源,因为我在环境中有db2驱动程序jar和附加服务。 如果没有,有人可以指出我错过了什么吗?

的pom.xml

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependenc

    <dependency>
        <groupId>com.ibm.db2</groupId>
        <artifactId>db2jcc </artifactId>
        <version>10.5</version>
   </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-cloudfoundry-connector</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-spring-service-connector</artifactId>
    </dependency>
</dependencies>

在提到下面给出我有以下的Spring上下文文件中配置链接。 使用云配置文件从我的本地数据源配置中分离。

spring config - 这是导入到我的spring上下文中,当我运行云配置文件时生效

<beans profile="cloud">
    <cloud:data-source id="dataSourcePref" service-name="test-sqldb">
        <!-- <cloud:pool-data-sources>
            <value>TomcatJdbc</value>
            <value>TomcatDbcp</value>
            <value>BasicDbcp</value>
        </cloud:pool-data-sources>-->
    </cloud:data-source>
</beans>    

Spring Boot应用程序类

@SpringBootApplication
@ImportResource("classpath:/META-INF/spring/my-jpa-beans.xml")
public class JpaTestApplication {

    public static void main(String[] args) {
       SpringApplication.run(JpaTestApplication.class, args);
    }
 }

错误

    2015-10-28T09:47:11.11-0700 [App/0]      OUT 2015-10-28 16:47:11.115 ERROR 29 --- [           main] o.s.boot.SpringApplication               : Application startup failed
2015-10-28T09:47:11.11-0700 [App/0]      OUT org.springframework.beans.factory.BeanCreationException: Error registering service factory; nested exception is org.springframework.cloud.CloudException: No suitable ServiceConnectorCreator found: service id=test-sqldb, service info type=org.springframework.cloud.service.BaseServiceInfo, connector type=interface javax.sql.DataSource
2015-10-28T09:47:11.11-0700 [App/0]      OUT    at org.springframework.cloud.config.xml.CloudServiceIntroducer.postProcessBeanFactory(AbstractCloudServiceFactoryParser.java:90)
2015-10-28T09:47:11.11-0700 [App/0]      OUT    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:265)
2015-10-28T09:47:11.11-0700 [App/0]      OUT    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:177)
2015-10-28T09:47:11.11-0700 [App/0]      OUT    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:607)
2015-10-28T09:47:11.11-0700 [App/0]      OUT    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:462)
2015-10-28T09:47:11.11-0700 [App/0]      OUT    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:117)
2015-10-28T09:47:11.11-0700 [App/0]      OUT    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:689)
2015-10-28T09:47:11.11-0700 [App/0]      OUT    at org.springframework.boot.SpringApplication.run(SpringApplication.java:321)
2015-10-28T09:47:11.11-0700 [App/0]      OUT    at org.springframework.boot.SpringApplication.run(SpringApplication.java:969)
2015-10-28T09:47:11.11-0700 [App/0]      OUT    at org.springframework.boot.SpringApplication.run(SpringApplication.java:958)
2015-10-28T09:47:11.11-0700 [App/0]      OUT    at com.example.JpaTestApplication.main(JpaTestApplication.java:14)
2015-10-28T09:47:11.11-0700 [App/0]      OUT    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2015-10-28T09:47:11.11-0700 [App/0]      OUT    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
2015-10-28T09:47:11.11-0700 [App/0]      OUT    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2015-10-28T09:47:11.11-0700 [App/0]      OUT    at java.lang.reflect.Method.invoke(Method.java:497)
2015-10-28T09:47:11.11-0700 [App/0]      OUT    at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53)
2015-10-28T09:47:11.11-0700 [App/0]      OUT    at java.lang.Thread.run(Thread.java:745)
2015-10-28T09:47:11.11-0700 [App/0]      OUT Caused by: org.springframework.cloud.CloudException: No suitable ServiceConnectorCreator found: service id=test-sqldb, service info type=org.springframework.cloud.service.BaseServiceInfo, connector type=interface javax.sql.DataSource
2015-10-28T09:47:11.11-0700 [App/0]      OUT    at org.springframework.cloud.ServiceConnectorCreatorRegistry.getServiceCreator(Cloud.java:356)
2015-10-28T09:47:11.11-0700 [App/0]      OUT    at org.springframework.cloud.Cloud.getServiceConnector(Cloud.java:255)
2015-10-28T09:47:11.11-0700 [App/0]      OUT    at org.springframework.cloud.Cloud.getServiceConnector(Cloud.java:142)
2015-10-28T09:47:11.11-0700 [App/0]      OUT    at org.springframework.cloud.service.AbstractCloudServiceConnectorFactory.createService(AbstractCloudServiceConnectorFactory.java:103)
2015-10-28T09:47:11.11-0700 [App/0]      OUT    at org.springframework.cloud.service.AbstractCloudServiceConnectorFactory.createInstance(AbstractCloudServiceConnectorFactory.java:98)
2015-10-28T09:47:11.11-0700 [App/0]      OUT    at org.springframework.beans.factory.config.AbstractFactoryBean.afterPropertiesSet(AbstractFactoryBean.java:134)
2015-10-28T09:47:11.11-0700 [App/0]      OUT    at org.springframework.cloud.service.AbstractCloudServiceConnectorFactory.afterPropertiesSet(AbstractCloudServiceConnectorFactory.java:93)
2015-10-28T09:47:11.11-0700 [App/0]      OUT    at org.springframework.cloud.config.xml.CloudServiceIntroducer.postProcessBeanFactory(AbstractCloudServiceFactoryParser.java:82)
2015-10-28T09:47:11.11-0700 [App/0]      OUT    ... 16 common frames omitted
2015-10-28T09:47:11.26-0700 [DEA/17]     ERR Instance (index 0) failed to start accepting connections

似乎我明白发生了什么。

这个帖子中的答案提到了一些提示给我的服务连接器。

SqlDb需要DB2DataSourceCreator,这在我使用的spring-cloud-connectors版本1.1.1发行版中不可用。 它支持MySQL,Postgres,Redis,MongoDB,RabbitMQ等其他产品。

升级到1.2.0版本,我可以通过此错误点。 感谢你们两个试图提供帮助的人。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM