Maven WAR依赖与Maven WAR插件-与eclipse构建冲突
我有一个包含java代码的war,并且需要使其他代码依赖于war中包含的代码。 我在别处读到过关于使用Maven WAR依赖与Maven WAR插件-与eclipse构建冲突,maven,war,Maven,War,我有一个包含java代码的war,并且需要使其他代码依赖于war中包含的代码。 我在别处读到过关于使用 <plugin> <artifactId>maven-war-plugin</artifactId> <version>2.4</version> <configuration> <attachClasses>true</attachClasses>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<attachClasses>true</attachClasses>
</configuration>
</plugin>
该项目可以通过两种方式进行编译(1)在命令行上使用eclipse中的mvn(2)作为标准项目(而不是maven项目)——我的公司就是这样做的
因此,我在mvn命令行上使用eclipse:eclipse进行编译,但这使得原始项目现在依赖于eclipse.classpath文件中的自身
这就是项目搜索war的.classpath文件现在包含的行
<classpathentry kind="src" path="/search-war"/>
如果不拆分项目,也就是说,为代码创建一个单独的模块(只创建一个jar文件),并将其设置为war以及任何其他需要它的项目中的依赖项 这种方式更加简洁,可以使用
eclipse:eclipse
以及m2e工作,并且在多模块构建中没有子文件问题(例如,当仅运行mvn compile
时,使用附加的工件无法按预期工作)
作为一般规则:不要在代码中使用附加的工件(带有分类器)。您的公司正在遵循一个几乎所有人都认为效率低下、成本高昂且容易出错的定制流程。唯一没有这种感觉的人也在做错事。使用maven,遵循它的过程,并蓬勃发展,然后向您的程序员同事和领导展示这种美德,希望他们能够学习并遵循您的领导。
<classpathentry kind="src" path="/search-war"/>
Solution:
There is a bug in the eclipse plugin.
But it only shows up under specific conditions...
The war was being renamed using the build/fileName tags.
When i disabled this - the problem disappeared - and all is fine.
(I just renamed the war in a post-build shell script instead).