maven 工程依賴war包

maven工程A須要依賴工程B的一些資源。A和B都是war包web

A工程:sql

<groupId>com.yonyou.zhu</groupId>
	<artifactId>RabbitMqExample</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<type>war</type>

B工程:apache

<groupId>com.yonyou.zhu</groupId>
	<artifactId>zhuweb</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<type>war</type>

首先在A工程的pom文件中引入B工程的pom依賴app

<dependency>
	        <groupId>com.yonyou.zhu</groupId>
	        <artifactId>zhuweb</artifactId>
	        <version>0.0.1-SNAPSHOT</version>
	        <type>war</type>
	</dependency>

而後在A工程引入webapp

<dependency>
       <groupId>com.yonyou.zhu</groupId>
       <artifactId>zhuweb</artifactId>
       <version>0.0.1-SNAPSHOT</version>
       <type>warpath</type>
</dependency>

<type>warpath</type>能夠將zhuweb war包的依賴 引入到當前war包maven

在A工程的pom文件中使用maven-war-plugin插件ui

<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.3</version>
				<configuration>
					<source>1.7</source>
					<target>1.7</target>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-war-plugin</artifactId>
				<version>2.6</version>
				<configuration>
					<warName>${project.artifactId}</warName>
					<!-- must set up , default value is target/war/work 不然致使被打包進war文件,指定後爲target/work -->
					<workDirectory>${project.build.directory}/work</workDirectory>
					<!-- default value is target/war/work -->
					<webappDirectory>target/ecmp-portal</webappDirectory>
					<useCache>false</useCache>
					<overlays>
						<overlay>
	                                                <groupId>com.yonyou.zhu</groupId>
	                                                <artifactId>zhuweb</artifactId>
							<type>war</type>
						</overlay>
					</overlays>
<!-- 排除zhuweb war包內的一些文件 -->
<dependentWarExcludes>*/web.xml,WEB-INF/lib/*,/sql-map-config.xml,/jdbc.properties,/META-INF/*</dependentWarExcludes>
				</configuration>
			</plugin>
		</plugins>
	</build>
相關文章
相關標籤/搜索