如何解决IntelliJ IDEA中Java文件的依赖项冲突? [英] How do I resolve dependency conflict for a Java file in IntelliJ IDEA?

查看:160
本文介绍了如何解决IntelliJ IDEA中Java文件的依赖项冲突?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在网络上搜索我面临的问题,但也许我不是在问Google正确的问题,所以我在这里.

I have tried to search web for the problem I am facing but maybe I am not asking google the right question so here I am.

我将IntelliJ IDEA用于我的多模块项目.对于我的一个模块,其中一个类文件正在使用静态导入-

I am using IntelliJ IDEA for my multi-module project. For one of my modules, one of the class file is using a static import -

import static javax.ws.rs.core.Response.Status.Family.familyOf;

作为一个大项目,有很多从内部存储库中下载的依赖项,但是由于某些原因IntelliJ拒绝使用依赖项"javax.ws.rs-api-2.0",而是使用了"jersey-core-1.8".因此,它引发编译错误,提示找不到符号"familyof".

Being a big project, there are a lot of dependencies downloaded from internal repo but for some reason IntelliJ refuses to use the dependency "javax.ws.rs-api-2.0" instead it is using "jersey-core-1.8". Because of this it is throwing a compilation error saying Cannot find symbol "familyof".

我从这两个依赖关系中查看了Response.java,发现jersey依赖关系不具有familyof方法,而javax.ws.rs-api-2.0却具有它,但是IntelliJ不使用此依赖关系.我该如何解决此问题.我们团队中的大多数开发人员都在使用Eclipse,但是他们没有这个问题.我试图适应IntelliJ IDE,但似乎无法找出解决方法.非常感谢这方面的任何帮助.

I looked into Response.java from both the dependencies and found that jersey dependency does not have familyof method while javax.ws.rs-api-2.0 has it but IntelliJ doesnt use this dependency. How do I fix this problem. Most of the developers in my team are using Eclipse and they do not have this problem. I am trying to get used to IntelliJ IDE but cant seem to figure a way out of this. Any help in this regard is much appreciated.

PS-在Eclipse IDE中不会发生此问题.

PS - This issue does not occur in Eclipse IDE.

推荐答案

通过使用pom.xml中的依赖项,并确保要获取的依赖项,您每次使用Maven都能获得正确的结果优先级在依赖项列表中首先声明.是的,在pom.xml中声明依赖项的顺序很重要!

You may be able to get the right result every time with Maven by shuffling around the dependencies in the pom.xml, and make sure the dependency you want to take precedence is declared first in the list of dependencies. yes, the order in which the dependencies are declared in pom.xml matters !

然后,如果你们所有人都使用相同的Maven版本,那么您应该获得一致的结果.

Then, if all of you are using the same Maven version, you should have a consistent result.

这篇关于如何解决IntelliJ IDEA中Java文件的依赖项冲突?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆