首页 > Web开发 > 详细

Maven 多web模块项目配置(多war合并)

时间:2015-07-24 02:11:15      阅读:477      评论:0      收藏:0      [点我收藏+]

???????有时候在一个项目中为了清晰划分不同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 的结构是“


bubuko.com,布布扣
?

在项目的主目录下执行?mvn -Dmaven.test.skip=true后


bubuko.com,布布扣

?

可以看到子web?module中的文件夹已经合并到主web中了,注意如果同名的文件夹和合并的,同时不合并空文件夹

?

?

?


?

?

Maven 多web模块项目配置(多war合并)

原文:http://zhangwei-david.iteye.com/blog/2229762

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!