簡體   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