0

我第一次尝试使用 Eclipse 2018-12 为 XNAT 导入 Gradle 项目。我创建了项目,右键单击,选择 Gradle,然后选择 Existing Gradle Project。导入完成后,SimpleUploadPlugin.java 出现错误 - “无法解析类型 org.apache.ecs.ConcreteElement。它是从所需的 .class 文件间接引用的”。我已经检查过了,我有 commons-lang3-3.8.1.jar。

请问我需要做什么来解决这个问题?

我的 build.gradle 依赖项是:

// TODO: This is a pretty minimal set of dependencies, so don't worry if you need to add more.
dependencies {
    implementation("org.nrg.xnat:web") {
        transitive = false
    }
    implementation("org.nrg.xnat:xnat-data-models") {
        transitive = false
    }
    implementation("org.nrg.xdat:core") {
        transitive = false
    }
    implementation "org.nrg:prefs"
    implementation "org.nrg:framework"

    implementation("turbine:turbine") {
        transitive = false
    }
    implementation("org.apache.velocity:velocity") {
        transitive = false
    }
    implementation("stratum:stratum") {
        transitive = false
    }

    implementation "log4j:log4j"
    implementation "io.springfox:springfox-swagger2"

    compile group: 'ecs', name: 'ecs', version: '1.4.2'
}
4

2 回答 2

1

另一种选择是将org.nrg.xnat:web的依赖配置从compileimplementation更改为compileOnly。这使您可以为插件声明更少的依赖项,因为您可以允许传递依赖项。ECS 依赖来自 XNAT 本身中的类,因此允许传递依赖意味着您不必声明可能被间接引用的所有内容。我刚刚在 XNAT LDAP 身份验证插件中进行了此更改,并从此开始:

implementation("org.nrg.xnat:web") {
    transitive = false
}
implementation("org.nrg.xnat:xnat-data-models") {
    transitive = false
}
implementation("org.nrg.xdat:core") {
    transitive = false
}
implementation("org.nrg:prefs") {
    transitive = false
}
implementation("org.nrg:framework") {
    transitive = false
}

implementation "org.springframework:spring-web"
implementation "org.springframework.security:spring-security-config"
implementation "org.springframework.security:spring-security-ldap"

implementation "org.apache.commons:commons-lang3"
implementation "org.hibernate.javax.persistence:hibernate-jpa-2.1-api"
implementation "com.google.guava:guava"
implementation "org.slf4j:slf4j-api"
implementation "log4j:log4j"

implementation "org.springframework.security:spring-security-web"
implementation "javax.servlet:javax.servlet-api"

compileOnly "com.google.code.findbugs:jsr305"
compileOnly "org.apache.ivy:ivy:2.4.0"
compileOnly("stratum:stratum") {
    transitive = false
}

对此:

compileOnly "org.nrg.xnat:web"
compileOnly "org.springframework.security:spring-security-ldap"
compileOnly "org.slf4j:slf4j-nop"

如果你运行这个:

$ ./gradlew dependencies

您会看到ecs:ecs:1.4.2通过许多传递依赖关系被引入。

于 2019-04-05T15:31:28.767 回答
0

org.apache.ecs.ConcreteElement来自Apache 元素构造集 (ECS),例如包含在ecs-1.4.2.jar.

要解决此问题,请在您的build.gradle文件中添加一个依赖项,如下所示:

// https://mvnrepository.com/artifact/ecs/ecs
compile group: 'ecs', name: 'ecs', version: '1.4.2'
于 2019-04-05T06:14:33.390 回答