java 找不到合适的 ServiceConnectorCreator 错误 - Spring cloud/CloudFoundry
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33399053/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
No suitable ServiceConnectorCreator found error - Spring cloud/CloudFoundry
提问by Hari Nair
All,
全部,
I have a spring boot app that gives me an error, when I try to push to IBM Bluemix/CloudFoundry.
当我尝试推送到 IBM Bluemix/CloudFoundry 时,我有一个 Spring Boot 应用程序给我一个错误。
This is a spring boot app, using spring cloud and trying to connect to a relational db service (sqldb which is a cloud version of DB2) service.
这是一个 spring boot 应用程序,使用 spring cloud 并尝试连接到关系数据库服务(sqldb 是 DB2 的云版本)服务。
I could connect without spring cloud, where I explicitly specified the db credentials from vcap_services in my property file. However I am trying to avoid that using spring cloud abstraction, but gets the error mentioned below.
我可以在没有 spring cloud 的情况下进行连接,我在我的属性文件中明确指定了来自 vcap_services 的数据库凭据。但是我试图避免使用 spring 云抽象,但得到了下面提到的错误。
My expectation is the spring boot/cloud should identify the test-sqldb service I bound to the app and create a data source on the fly. Instead I get the error given below when I do cf push.
我的期望是 spring boot/cloud 应该识别我绑定到应用程序的 test-sqldb 服务并动态创建数据源。相反,当我执行 cf push 时,我得到了下面给出的错误。
Is it fair to assume that spring boot/cloud pair will orchestrate the data source for me as I have the db2 driver jar and attached service in environment.? If not, can some one point to me what am I missing?
假设 spring boot/cloud 对将为我编排数据源是否公平,因为我在环境中有 db2 驱动程序 jar 和附加服务。?如果没有,有人可以指出我缺少什么吗?
Pom.xml
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>
I have following config in spring context file as given below as mentioned in thislink. Using the cloud profile to separate from my local datasource config.
在提到下面给出我有以下的Spring上下文文件中配置该链接。使用云配置文件与我的本地数据源配置分开。
spring config- this is imported to my spring context and is in effect when I run with cloud profile
spring 配置- 这将导入到我的 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 Application Class
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);
}
}
Error
错误
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
回答by Hari Nair
Seems I understood what is happening.
似乎我明白发生了什么。
An answer in thisthread mentions about Service connectors that gave me a hint.
该线程中的一个答案提到了给我提示的服务连接器。
SqlDb need DB2DataSourceCreator which was not available in spring-cloud-connectors version 1.1.1-release, which I was using. It supports others like MySQL, Postgres, Redis, MongoDB, RabbitMQ, etc..
SqlDb 需要 DB2DataSourceCreator,这在我使用的 spring-cloud-connectors 1.1.1-release 版本中不可用。它支持其他如 MySQL、Postgres、Redis、MongoDB、RabbitMQ 等。
Upgraded to 1.2.0-release and I am able to pass this error point. Thanks for two of you who tried to help.
升级到 1.2.0-release,我能够通过这个错误点。感谢你们中的两个试图提供帮助的人。