maven指定項目的構建、打包和tomcat插件的pom.xml配置


1、pom.xml添加如下配置:

<build>
<finalName>${parent.artifactId}</finalName>
<plugins>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<uriEncoding>UT-8</uriEncoding>
<port>8088</port>
<path>/</path>
</configuration>

</plugin>

<!-- 打包插件, 便於部署 -->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.5</version>
<configuration>
<descriptors>
<!-- 指定描述文件 -->
<descriptor>../assembly.xml</descriptor>
</descriptors>
<!-- 輸出文件一定要放到項目根目錄的target 目錄下,
當前此插件在web子模塊執行,其parent 才是項目根目錄 -->
<outputDirectory>${project.parent.build.directory}</outputDirectory>
</configuration>
<executions>
<execution>
<id>packaging</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>


2、
assembly.xml如下:
<?xml version="1.0" encoding="UTF-8"?>
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">

<!-- 與maven assembly plugin 配合使用 -->

<id>assembly</id>
<!-- 使用項目名稱 -->
<baseDirectory>/</baseDirectory>
<formats>
<!-- 壓縮格式 -->
<format>tar.gz</format>
</formats>
<fileSets>
<fileSet>
<!-- web 項目 直接指定 打包目錄
需要在web 模塊的 pom 指定 finalName 為 項目名稱
-->
<directory>target/${project.build.finalName}</directory>
<outputDirectory>/</outputDirectory>
</fileSet>
</fileSets>

</assembly>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM