我有一个模块,用来制作两个工件(war的)。这两场战争之间唯一的区别是使用了web.xml。
我是在Maven档案的帮助下这么做的..。
<parent>
<artifactId>com</artifactId>
<groupId>myProj</groupId>
<version>1.0</version>
</parent>
<groupId>myProj.module1</groupId>
<artifactId>module1</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<profiles>
<profile>
<id>module1</id>
<build>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warName>module1</warName>
<webXml>src\main\webapp\WEB-INF\web_module1.xml</webXml>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>module2</id>
<build>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warName>module2</warName>
<webXml>src\main\webapp\WEB-INF\web_module2.xml</webXml>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
Q1:我如何从超级POM中调用这个POM,以便激活两个概要文件?
Q2:可以在本地存储库中安装两个生成的工件吗?
谢谢!
发布于 2011-02-17 02:56:20
当您想要同时激活多个配置文件时,只需运行mvn ... -Pprofile1,profile2
命令即可。
但是,在您的示例中,这是针对一个主要的Maven约定的,该约定声明one project = one artifact
。这意味着你不能同时制造2场战争。如果激活了这两个配置文件,那么maven-war-plugin
的一个配置将被第二个配置文件覆盖,然后,您将最终得到一个WAR,使用一个web.xml。
如果您想获得2个war,解决方案是使用战争覆盖 (即第二个war是另一个依赖于war#1的项目),或者运行两个单独的Maven命令,每个配置文件一个。
https://stackoverflow.com/questions/5027937
复制相似问题