Maven编译错误:重复的类 [英] maven compilation error: duplicate classes
问题描述
在我的maven2项目中,我有一个目录${basedir}/autogen
,其中包含一些由wsdl2java
生成的自动生成的源代码文件.
In my maven2 project I have a directory ${basedir}/autogen
that contains some autogenerated source code files produced by wsdl2java
.
运行mvn compile
时,由于类重复,我得到了一个编译错误,该错误驻留在${basedir}/autogen
中.这是真实的.但是${basedir}/autogen
中的编译阶段在做什么?我没有告诉过maven将此目录添加为源目录.
而且似乎没有办法告诉Maven忽略目录.
When running mvn compile
I get an compilation error, because of duplicate classes, that lives in ${basedir}/autogen
. This is true. But what is the compilation phase doing in ${basedir}/autogen
? I have not told maven to add this directory as a source directory.
And there seems to be no way of telling maven to ignore the directory.
推荐答案
在使用maven-processor-plugin时,我遇到了同样的问题,发现解决方案是按以下方式配置maven-compiler插件:
I had the same problem when using the maven-processor-plugin and found that the solution was to configure the maven-compiler plugin as follows:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerArgument>-proc:none</compilerArgument>
</configuration>
</plugin>
-proc:none意味着无需注释处理即可进行编译,因此没有重复的类(通常在generate-sources阶段生成)
-proc:none means that compilation takes place without annotation processing and therefore no duplicate classes (which are typically generated in the generate-sources phase)
我希望能帮上忙.
这篇关于Maven编译错误:重复的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!