???????有时候在一个项目中为了清晰划分不同web模块需要配置多个web module 。如:
?
<modules> <!-- 主web应用 --> <module>cathy-web</module> <module>cathy-biz</module> <module>cathy-common-util</module> <module>cathy-common-intergration</module> <module>cathy-common-facade</module> <module>cathy-common-model</module> <module>cathy-common-dal</module> <module>cathy-core-service</module> <!-- 子web应用 --> <module>cathy-backend</module> </modules>
?配置看起来很?简单,在打包的时候需要将这两个web打成一个war包又该如何配置呢?此时就需要使用到maven-war-plugin这个插件,当然这个插件的功能不仅仅是将多个war包合并成一个war.
??在 cathy-web?这个module的pom?中的dependencies进行如下配置
?
<dependency> <groupId>com.david.demo</groupId> <artifactId>cathy-backend</artifactId> <type>war</type> </dependency>
??在plugins增加如下配置
<!-- 合并多个war --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <configuration> <packagingExcludes>WEB-INF/web.xml</packagingExcludes> <failOnMissingWebXml>false</failOnMissingWebXml> <overlays> <overlay> <groupId>com.david.demo</groupId> <artifactId>cathy-backend</artifactId> </overlay> </overlays> </configuration> </plugin>
???在主pom中的依赖中增加
<dependency> <groupId>com.david.demo</groupId> <artifactId>cathy-backend</artifactId> <version>0.0.1-SNAPSHOT</version> <type>war</type> <scope>runtime</scope> </dependency>
?
? 子web module 的结构是“
?
在项目的主目录下执行?mvn -Dmaven.test.skip=true后
?
可以看到子web?module中的文件夹已经合并到主web中了,注意如果同名的文件夹和合并的,同时不合并空文件夹
?
?
?
?
?
原文:http://zhangwei-david.iteye.com/blog/2229762