Intellij IDEA编辑器:类路径顺序 [英] Intellij IDEA editor: classpath order

查看:136
本文介绍了Intellij IDEA编辑器:类路径顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图为此寻找一种解决方案,但并不高兴:在Intellij IDEA中,我设置了一组模块,以便拥有以下内容:

I've tried to search for a solution for this, but have had no joy: In Intellij IDEA I've set up a set of modules so that I have the following:

  • 我的Web项目(所有模块依赖项都设置为运行时")
  • 我的Web项目依赖性#1(+将JAR复制到MWP的/WEB-INF/lib的工件)
  • 我的Web项目依赖项2(+将JAR复制到MWP的/WEB-INF/lib的工件)

Dependency#1的类为org.acme.foo,但MWP的定义也有所不同(哦,喜悦).它可以正常运行-MWP中的所有代码都可以根据MWP中的类而不是Dependency#1正确构建.

Dependency#1 has a class org.acme.foo, but so does MWP and the definition differs (oh joy). It builds ok - all code in MWP correctly builds against the classes in MWP instead of Dependency#1.

但是...在Intellij的编辑器中,它是红色的,因为它更喜欢使用不兼容的定义引用Dependency#1中的类.

But...in its editor, Intellij is giving me the red squiggle because it's preferring to reference the class in Dependency#1 with its incompatible definition.

忽略了这样的事实,那就是真的不应该发生此类/程序包冲突,有人可以帮助我推动Intellij来查看本地模块中的类,而不是依赖项中的类吗?

Ignoring the fact that there really shouldn't be this class/package clash, can anyone help me push Intellij into looking at the class in the local module, and not at the class in the dependency?

我正在使用最新的Intellij 11.

I'm using the latest Intellij 11.

对于任何发现此问题的人,这些麻烦在Intellij 12+中就消失了

for anyone finding this question, these troubles went away in Intellij 12+

推荐答案

我在IntelliJ 11(Mac OS X版本)中也遇到了同样的问题.

I was facing the same issue in IntelliJ 11 (Mac OS X version).

我手动编辑了项目的.iml文件,并以正确的顺序重新排列了依赖项:我将包含正确版本的.jar文件的orderEntry元素放在顶部.

I manually edited my project's .iml file and re-arranged the dependencies in the right order: I put the orderEntry element containing the right version of the .jar file on top.

希望这会有所帮助.

这篇关于Intellij IDEA编辑器:类路径顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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