为 XNAT 导入 Gradle 项目时出现问题 - 未解析的类型
Issue with importing a Gradle project for XNAT - unresolved type
我第一次尝试使用 Eclipse 2018-12 为 XNAT 导入 Gradle 项目。我创建了项目,单击鼠标右键,选择 Gradle,然后选择现有的 Gradle 项目。导入完成后出现 SimpleUploadPlugin.java - "The type org.apache.ecs.ConcreteElement cannot be resolved. It is indirectly referenced from required .class files" 错误。我检查过,我有 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'
}
org.apache.ecs.ConcreteElement
来自 Apache Element Construction Set (ECS) and for example contained in ecs-1.4.2.jar
.
要解决此问题,请将依赖项添加到您的 build.gradle
文件,如下所示:
// https://mvnrepository.com/artifact/ecs/ecs
compile group: 'ecs', name: 'ecs', version: '1.4.2'
另一种选择是从 compile 或 implementation 更改 org.nrg.xnat:web 的依赖配置 到 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 通过许多传递依赖项被引入。
我第一次尝试使用 Eclipse 2018-12 为 XNAT 导入 Gradle 项目。我创建了项目,单击鼠标右键,选择 Gradle,然后选择现有的 Gradle 项目。导入完成后出现 SimpleUploadPlugin.java - "The type org.apache.ecs.ConcreteElement cannot be resolved. It is indirectly referenced from required .class files" 错误。我检查过,我有 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'
}
org.apache.ecs.ConcreteElement
来自 Apache Element Construction Set (ECS) and for example contained in ecs-1.4.2.jar
.
要解决此问题,请将依赖项添加到您的 build.gradle
文件,如下所示:
// https://mvnrepository.com/artifact/ecs/ecs
compile group: 'ecs', name: 'ecs', version: '1.4.2'
另一种选择是从 compile 或 implementation 更改 org.nrg.xnat:web 的依赖配置 到 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 通过许多传递依赖项被引入。