Maven WAR 依赖项 [英] Maven WAR dependency
问题描述
我正在编写一个用于验收测试的项目,由于各种原因,这依赖于另一个打包为 WAR 的项目.我已经设法使用 maven-dependency-plugin 解压 WAR,但我无法让我的项目包含解压的 WEB-INF/lib/*.jar
和 WEB-INF/classes/*
包含在类路径中,因此构建失败.有没有办法将这些文件包含到类路径中,或者有没有更好的方法来依赖 WAR?
I am writing a project for acceptance testing and for various reasons this is dependent on another project which is packaged as a WAR. I have managed to unpack the WAR using the maven-dependency-plugin, but I cannot get my project to include the unpacked WEB-INF/lib/*.jar
and WEB-INF/classes/*
to be included on the classpath so the build fails. Is there a way to include these files into the classpath, or is there a better way of depending on a WAR?
非常感谢.
推荐答案
自 maven-war-plugin 2.1-alpha-2 以来,还有另一个选择.在您的 WAR 项目中:
There's another option since maven-war-plugin 2.1-alpha-2. In your WAR project:
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<attachClasses>true</attachClasses>
</configuration>
</plugin>
这将创建一个类工件,您可以在验收测试项目中使用它:
This creates a classes artifact which you can use in the acceptance tests project with:
<dependency>
<groupId>your-group-id</groupId>
<artifactId>your-artifact-id</artifactId>
<version>your-version</version>
<classifier>classes</classifier>
</dependency>
这篇关于Maven WAR 依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!