“找到重复的类” - IntelliJ和.class文件 [英] "Duplicate class found" - IntelliJ and .class files
问题描述
我最近将我们公司的一个项目导入IntelliJ Idea(10.5.1)。我们使用 ant 构建脚本构建并运行项目,IntelliJ支持就好了。
I recently imported one of our company's project into IntelliJ Idea (10.5.1). We build and run the project using an ant build script and IntelliJ supports that just fine.
然而,IntelliJ似乎有一个明显的问题编译输出目录等于源代码目录,即 .class
文件放在与其对应的 .java
来源。
However, IntelliJ seems to have a distinct problem when the compile output directory equals the source code directory, ie .class
files are placed in the same directories as their corresponding .java
sources.
(请注意,我知道这不是一个正确的方法,但告诉我的老板。这个项目超过15年,相应大,太多的东西都依赖于它,这是我无能为力的。)
(Note that I am aware that is not a proper way to go, but tell my boss that. This project is over 15 years old and correspondingly large, too many things depend on it to be this way, there is nothing I can do about that.)
因此,一旦编译完成,IntelliJ就会检测到 .class
文件并将它们添加到项目树中。这里的问题是它认为它们是类声明,因此我得到了每个类的找到重复的类消息。这不会让我无法工作,但你可能会猜到它非常烦人。
So once things are compiled, IntelliJ detects the .class
files and adds them to the project tree. The problem here is that it considers them class declarations, thus I get a "duplicate class found" message for each and every class. This doesn't make me unable to work, but it is extremely annoying as you may guess.
我试图让IDE忽略 .class
文件,但显然这使得它根本不加载任何类,包括JRE运行时和位于 .jar
文件内的任何其他内容。
I tried making the IDE ignore .class
files, but apparently that makes it not load any classes at all, including the JRE runtime and anything else located inside of .jar
files.
有没有办法让IntelliJ Idea忽略 .class
与 .java
sources?
Is there any way to make IntelliJ Idea ignore .class
files which are in the same location as their .java
sources?
推荐答案
确保已将输出目录配置为源目录,禁用输出目录的排除以查看文件。
Make sure that you've configured the output directory to the source directory, disable the Exclude of the output directory to see your files.
这篇关于“找到重复的类” - IntelliJ和.class文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!