在Java9 +

时间:2019-03-12 09:48:07

标签: java gradle java-11

我正在尝试将旧项目迁移到Java 11。

dependencies {
    implementation ('com.google.code.findbugs:jsr305:3.0.2')
    implementation ('javax.xml.ws:jaxws-api:2.3.1')
}

这两个都包含注释,其他库则像这样抱怨它们:

error: module jsr305 reads package javax.annotation from both java.annotation and jsr305
error: module vboxjws reads package javax.annotation from both java.annotation and jsr305
error: module io.sentry reads package javax.annotation from both java.annotation and jsr305
error: module com.fasterxml.jackson.databind reads package javax.annotation from both java.annotation and jsr305
error: module com.fasterxml.jackson.dataformat.yaml reads package javax.annotation from both java.annotation and jsr305
error: module com.fasterxml.jackson.annotation reads package javax.annotation from both java.annotation and jsr305

我找到的解决方案是3:

1

configurations.all {
    exclude module: 'javax.annotation-api'
}

2

configurations.all {
resolutionStrategy {
        preferProjectModules()
        dependencySubstitution {

            substitute(module("javax.annotation:javax.annotation-api")).with(module("com.google.code.findbugs:jsr305:3.0.2"))

}}}

3

implementation ('javax.xml.ws:jaxws-api:2.3.1') {
        exclude group: 'javax.annotation', module: 'javax.annotation-api'
    }

它们都导致另一个错误:

Error occurred during initialization of boot layer
java.lang.module.FindException: Module java.annotation not found, required by java.xml.ws

这是一个示例,我在项目中大约有20个库,并且存在多个冲突,我读到另一种选择是将所有jar手动组合成一个,但我真的想避免这种情况。有没有办法解决Gradle中的这个问题?

0 个答案:

没有答案