首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不兼容,因为该组件声明了一个与Java 11兼容的组件,并且使用者需要一个与Java 10兼容的组件

不兼容,因为该组件声明了一个与Java 11兼容的组件,并且使用者需要一个与Java 10兼容的组件
EN

Stack Overflow用户
提问于 2022-05-04 18:32:48
回答 1查看 18.3K关注 0票数 19

在我的build.gradle文件中,我升级了一个依赖项的版本(即: com.db:microservice-commons)。加载gradle更改后,我得到以下错误消息:

代码语言:javascript
复制
> Build file 'C:\Projects\Container\mschmidt\mount\booking-service\standalone\build.gradle' line: 50

   > A problem occurred evaluating project ':standalone'.
   > Could not resolve all files for configuration ':standalone:runtimeClasspath'.
   > Could not resolve com.db:microservice-commons:2.4.1.
     Required by:
         project :standalone
         project :standalone > project :service
      > No matching variant of com.db:microservice-commons:2.4.1 was found. The consumer was configured to find a runtime of a library compatible with Java 10, packaged as a jar, preferably optimized for standard JVMs, and its dependencies declared externally but:
          - Variant 'apiElements' capability com.db:microservice-commons:2.4.1 declares a library, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares an API of a component compatible with Java 11 and the consumer needed a runtime of a component compatible with Java 10
              - Other compatible attribute:
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
          - Variant 'runtimeElements' capability com.db:microservice-commons:2.4.1 declares a runtime of a library, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares a component compatible with Java 11 and the consumer needed a component compatible with Java 10
              - Other compatible attribute:
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
          - Variant 'samplessources' capability com.db:microservice-commons:2.4.1:
              - Incompatible because this component declares documentation and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                  - Doesn't say anything about its target Java version (required compatibility with Java 10)
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Doesn't say anything about its usage (required a runtime)

文件'C:\Projects\Container\mschmidt\mount\booking-service\standalone\build.gradle‘的50+行如下所示:

代码语言:javascript
复制
 manifest {
    def manifestClasspath = configurations.runtimeClasspath.collect { it.getName() }.join(' ')
    attributes 'Archiver-Version': 'Plexus Archiver'
    attributes 'Build-Jdk': org.gradle.internal.jvm.Jvm.current()
    attributes 'Main-Class': 'com.db.service.standalone.Standalone', 'Class-Path': manifestClasspath
    }
}

我不知道这是怎么回事。项目JDK和Gradle JVM设置为Java11。同样的问题,但对我没有帮助。

有什么好主意吗?

EN

回答 1

Stack Overflow用户

发布于 2022-05-05 08:17:05

好吧,我发现问题了。

build.gradle文件中有以下两行:

代码语言:javascript
复制
 sourceCompatibility = 10
 targetCompatibility = 10

他们需要改到11。然后就成功了。

票数 14
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72117858

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档