mat*_*eny 5 java rest web-services gradle
我遇到了一个问题,在我的类路径中出现了同一个类的多个版本.有问题的课程是javax.ws.rs.core.UriBuilder.我想要使用的版本是由javax.ws.rs:javax.ws.rs-api:2.0.1.但是,我们还使用Jira rest客户端库,该库依赖于旧版本的jersey(com.sun.jersey:jersey-core),其中包含捆绑在其jar中的java.ws包.
以下是构建文件中的示例代码段:
dependencies {
compile 'com.atlassian.jira:jira-rest-java-client-core:2.0.0-m31'
compile 'javax.ws.rs:javax.ws.rs-api:2.0.1'
compile 'org.glassfish.jersey.core:jersey-client:2.17'
}
Run Code Online (Sandbox Code Playgroud)
我无法删除,com.sun.jersey:jersey-core因为它使用新版本中的不同包名称,并将导致Jira客户端中的类def def found异常.
据我所知,我现在的选择是:
javax.ws从旧的泽西客户端中排除了包裹.我想继续使用更新版的球衣,所以#2将是我理想的解决方案,但我不确定它是否可能.有谁知道如何去做?如果那是不可能的,我会接受其他建议.
您可以排除这样的传递依赖模块:
compile ('org.glassfish.jersey.core:jersey-client:2.17') {
exclude group: 'javax.ws.rs'
exclude module: 'javax.ws.rs-api'
}
Run Code Online (Sandbox Code Playgroud)
ref:50.4.7 here
我发现 com.sun.jersey:jersey-core:1.19 没有捆绑 javax.ws.rs 类文件,而是将它们列为编译时依赖项。将此代码片段添加到我的 build.gradle 中解决了该问题。
configurations.all {
resolutionStrategy {
// For a version that doesn't package javax.ws
force 'com.sun.jersey:jersey-core:1.19'
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14706 次 |
| 最近记录: |