提供者org.springframework.cloud.cloudfoundry.CloudFoundryConnector无法实例化 [英] Provider org.springframework.cloud.cloudfoundry.CloudFoundryConnector could not be instantiated

查看:160
本文介绍了提供者org.springframework.cloud.cloudfoundry.CloudFoundryConnector无法实例化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究将部署到cloudfoundry的grails 2.5.3应用程序。该应用程序绑定的服务很少,为了获得这些服务的值,我使用了两个连接器:

  // s3服务连接器
compile(org.cloudfoundry.community:spring-cloud-s3-service-connector:1.0.0){
不包括aws-java-sdk,slf4j-api, slf4j-log4j12','slf4j'
}
// sso服务连接器
编译(组:'io.pivotal.spring.cloud',名称:'spring-cloud-sso-connector ',版本:'1.1.0.RELEASE'){
不包括'slf4j-api','slf4j-log4j12','slf4j'
}

当我使用这两种方法时,我的应用程序中出现错误:


org.springframework.cloud.CloudConnector:Provider
org.springframework.cloud.cloudfoundry.CloudFoundryConnector不能
被实例化



引起:java.lang.NoSuchMethodError:
org.springframework.cloud.cloudfoundry.CloudFoundryServiceInfoCreator。(Lorg / sprin gframework / cloud / cloudfoundry / Tags; [Ljava / lang / String;)v
at io.pivotal.spring.cloud.SsoServiceInfoCreator。(SsoServiceInfoCreator.java:11)​​




我相信错误发生是因为这些服务中的每一个都在 META-INF下有一个 services 文件夹显然只有一个是同时使用这两个选项。



c $ c>

SSO连接器: https://github.com/pivotal-cf/spring-cloud-sso-connector/tree/master/src/main/resources/META-INF/services



连接器: https://github.com/cloudfoundry-community/spring-cloud-s3-service-connector/tree/master/src/main/resources/META-INF/services



我不确定如何解决此错误。我尝试了各种组合,但似乎没有工作。

更新



我已经添加了与此相关的第二个问题 https://stackoverflow.com/问题/ 42976791 / common-dependency-for-two-packages-gets-dropped-when-both-pages-are-used

解决方案

在类路径中有多个Connector扩展库是常见的,每个都有自己的 META-INF / services 。这应该不成问题。



  compile(org.cloudfoundry。社区:spring-cloud-s3-service-connector:1.0.0){
不包括aws-java-sdk,slf4j-api,slf4j-log4j12,slf4j
}
//依赖关系树显示
+ --- org.cloudfoundry.community:spring-cloud-s3-service-connector:1.0.0
| \ --- org.springframework.cloud:spring-cloud-cloudfoundry-connector:1.0.0.RELEASE
| \ --- org.springframework.cloud:spring-cloud-core:1.0.0.RELEASE
| \ --- org.hamcrest:hamcrest-all:1.3

 编译(组:'io.pivotal.spring.cloud',名称:'spring-cloud-sso-connector',版本:'1.1.0 .RELEASE'){
不包括'slf4j-api','slf4j-log4j12','slf4j','spring-cloud-starter-oauth2'
}
//依赖关系树显示
+ --- io.pivotal.spring.cloud:spring-cloud-sso-connector:1.1.0.RELEASE
| \ --- org.springframework.cloud:spring-cloud-spring-service-connector:1.1.1.RELEASE
| \ --- org.springframework.cloud:spring-cloud-core:1.1.1.RELEASE
| \ --- org.springframework.cloud:spring-cloud-cloudfoundry-connector:1.1.1.RELEASE

这表明 spring-cloud-s3-service-connector:1.0.0 依赖于 spring-cloud-core:1.0.0 .RELEASE ,而 spring-cloud-sso-connector:1.1.0.RELEASE 取决于 spring-cloud-core :1.1.1.RELEASE 。构建系统只会引入一个版本的 spring-cloud-core ,看起来 spring-cloud-core:1.0.0.RELEASE 是真正被拉入的版本,并且 spring-cloud-sso-connector 与旧版本不兼容。

spring-cloud-s3-service-connector:1.1.0 可在 Maven Central ,请尝试升级到该版本。

I am working on a grails 2.5.3 app that will be deployed to cloudfoundry. The app is bound with few services and in order to get the values for those services I use two connectors:

//s3 service connector
compile ("org.cloudfoundry.community:spring-cloud-s3-service-connector:1.0.0") {
    excludes "aws-java-sdk", 'slf4j-api', 'slf4j-log4j12', 'slf4j'
}     
//sso service connector
compile (group: 'io.pivotal.spring.cloud', name: 'spring-cloud-sso-connector', version: '1.1.0.RELEASE') {
    excludes 'slf4j-api', 'slf4j-log4j12', 'slf4j'
}

When I use both of these I get an error in my application:

org.springframework.cloud.CloudConnector: Provider org.springframework.cloud.cloudfoundry.CloudFoundryConnector could not be instantiated

Caused by: java.lang.NoSuchMethodError: org.springframework.cloud.cloudfoundry.CloudFoundryServiceInfoCreator.(Lorg/springframework/cloud/cloudfoundry/Tags;[Ljava/lang/String;)V at io.pivotal.spring.cloud.SsoServiceInfoCreator.(SsoServiceInfoCreator.java:11)

I believe the error is happening because each of these services have a services folder under META-INF and apparently only one is picked when both of these are used simultaneously.

The META-INF/services folder for both is here:

SSO Connector: https://github.com/pivotal-cf/spring-cloud-sso-connector/tree/master/src/main/resources/META-INF/services

S3 Connector: https://github.com/cloudfoundry-community/spring-cloud-s3-service-connector/tree/master/src/main/resources/META-INF/services

I'm not sure how to resolve this error. I've tried various combinations but none seem to work.

Update

I've added a second question that is related to this https://stackoverflow.com/questions/42976791/common-dependency-for-two-packages-gets-dropped-when-both-pages-are-used

解决方案

Having multiple Connector extension libs on the classpath is common, each with their own META-INF/services. This shouldn't be a problem.

In your other question, you have:

compile ("org.cloudfoundry.community:spring-cloud-s3-service-connector:1.0.0") {
    excludes "aws-java-sdk", 'slf4j-api', 'slf4j-log4j12', 'slf4j'
}
//dependency tree shows 
+--- org.cloudfoundry.community:spring-cloud-s3-service-connector:1.0.0
|    \--- org.springframework.cloud:spring-cloud-cloudfoundry-connector:1.0.0.RELEASE
|         \--- org.springframework.cloud:spring-cloud-core:1.0.0.RELEASE
|    \--- org.hamcrest:hamcrest-all:1.3

and

compile (group: 'io.pivotal.spring.cloud', name: 'spring-cloud-sso-connector', version: '1.1.0.RELEASE') {
    excludes 'slf4j-api', 'slf4j-log4j12', 'slf4j', 'spring-cloud-starter-oauth2'
}
//dependency tree shows
+--- io.pivotal.spring.cloud:spring-cloud-sso-connector:1.1.0.RELEASE
|    \--- org.springframework.cloud:spring-cloud-spring-service-connector:1.1.1.RELEASE
|         \--- org.springframework.cloud:spring-cloud-core:1.1.1.RELEASE
|    \--- org.springframework.cloud:spring-cloud-cloudfoundry-connector:1.1.1.RELEASE

This shows that spring-cloud-s3-service-connector:1.0.0 transitively depends on spring-cloud-core:1.0.0.RELEASE, while spring-cloud-sso-connector:1.1.0.RELEASE depends on spring-cloud-core:1.1.1.RELEASE. The build system will only pull in one version of spring-cloud-core, and it appears that spring-cloud-core:1.0.0.RELEASE is the one that is actually getting pulled in and spring-cloud-sso-connector isn't compatible with that older version.

There is a spring-cloud-s3-service-connector:1.1.0 available in Maven Central, try upgrading to that version.

这篇关于提供者org.springframework.cloud.cloudfoundry.CloudFoundryConnector无法实例化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆