问题描述
我正在编写一个用于验收测试的项目,由于各种原因,这取决于打包为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依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!