This dependency gives me two versions of one jar. How do I fix this?

空扰寡人 提交于 2019-12-05 08:46:59

It appears that you have a dependency tree akin

project
|--- org.glassfish.jersey.media:jersey-media-moxy:2.0
| \--- *:javax.inject:1
\--- *:javax.inject:2.3.0-b05

Where * is the group, which I suspect may be different from those two.

Try getting an idea of how your dependencies are being grabbed by using the dependency task

gradle dependency

Should you need to exclude a dependency enter it in the tag, similar to the below example

compile('org.hibernate:hibernate:3.1') {
  //excluding a particular transitive dependency:
  exclude module: 'cglib' //by artifact name
  exclude group: 'org.jmock' //by group
  exclude group: 'org.unwanted', module: 'iAmBuggy' //by both name and group
}

Normally gradle will only include 1 jar per dependency. If different version found for the same depedencies, the newer version will be used.

However, in your case, these 2 jars are dependencies with different group names:

'javax.inject:javax.inject:1'
'org.glassfish.hk2.external:javax.inject:2.3.0-b05'

That's why gradle included both as they are treated as different dependencies.

'javax.inject:javax.inject:1' is very old, I think you should exclude it like what Niels Bech Nielsen said.

To find out where is this dependency come from , you can use command:

gradle -q dependencyInsight --dependency inject
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!