Exclude Package From Gradle Dependency

前端 未结 2 1901
执念已碎
执念已碎 2021-01-19 00:44

I\'m experiencing an issue where multiple versions of the same class are showing up in my classpath. The class in question is javax.ws.rs.core.UriBuilder. The

相关标签:
2条回答
  • 2021-01-19 01:11

    I found out that com.sun.jersey:jersey-core:1.19 doesn't bundle the javax.ws.rs class files and instead lists them as a compile-time dependency. Adding this snippet to my build.gradle fixed the issue.

    configurations.all {
      resolutionStrategy {
        // For a version that doesn't package javax.ws
        force 'com.sun.jersey:jersey-core:1.19' 
      }
    }
    
    0 讨论(0)
  • 2021-01-19 01:32

    You can exclude an transitive dependency module like this:

       compile ('org.glassfish.jersey.core:jersey-client:2.17') {
          exclude group: 'javax.ws.rs'
          exclude module: 'javax.ws.rs-api'
       }
    

    ref: 50.4.7 here

    0 讨论(0)
提交回复
热议问题