maven打包時,將war輸出到指定目錄,並重命名。

配置pom.xml文件, 添加插件:

<!-- 打包時即package 時將war打到指定目錄 -->
			<plugin>
			    <groupId>org.apache.maven.plugins</groupId>
			    <artifactId>maven-dependency-plugin</artifactId>
			    <version>2.8</version>
			    <executions>
			        <execution>
			            <id>copy-war</id>
			            <phase>package</phase>
			            <goals>
			                <goal>copy</goal>
			            </goals>
			            <configuration>
							<artifactItems>
								<artifactItem>
									<groupId>${project.groupId}</groupId>
									<artifactId>${project.artifactId}</artifactId>
									<version>${project.version}</version>
									<type>${project.packaging}</type>
									<destFileName>ROOT.war</destFileName><!-- 重寫目標文件名稱 -->
								</artifactItem>
							</artifactItems>
			                <outputDirectory>/opt/apache-tomcat-7.0.90/webapps</outputDirectory>
<!-- 			                <outputDirectory>D://d/p</outputDirectory> -->
			                <includes>
			                    <include>*.war</include>
			                </includes>
			                <stripVersion>true</stripVersion>
			            </configuration>
			        </execution>
			    </executions>
			</plugin>

<build><plugins> 添加在這個位置</plugins></build>

outputDirectory:是輸出的目錄

destFileName: 是目標的文件名(如果不寫,則會使用artifactId+ version 命名)

 

發佈了124 篇原創文章 · 獲贊 15 · 訪問量 4萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章