首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

maven封装web项目时同时打包为war和jar文件

2012-07-04 
maven打包web项目时同时打包为war和jar文件首先在pom.xml文件中指定war的打包方式,war然后在pom文件的plug

maven打包web项目时同时打包为war和jar文件
首先在pom.xml文件中指定war的打包方式,war

然后在pom文件的plugins节点下面增加如下内容即可mvn package时同时生成war, jar包。为了 mvn package install, mvn package deploy能够同时部署jar包,我们增加了后面2节点的配置:

<!--  package jar on package --><plugin>  <groupId>org.apache.maven.plugins</groupId>  <artifactId>maven-jar-plugin</artifactId>  <executions>  <execution>    <id>make-a-jar</id>    <phase>compile</phase>    <goals>      <goal>jar</goal>    </goals>  </execution>  </executions></plugin><!--  install jar to local repository --><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-install-plugin</artifactId><executions><execution><phase>install</phase><goals><goal>install-file</goal></goals><configuration><packaging>jar</packaging><artifactId>${project.artifactId}</artifactId><groupId>${project.groupId}</groupId><version>${project.version}</version><file>${project.build.directory}/${project.artifactId}-${project.version}.jar</file></configuration></execution></executions></plugin><!--  deploy jar to remote repository --><plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-deploy-plugin</artifactId> <executions> <execution> <phase>deploy</phase> <goals>  <goal>deploy-file</goal> </goals> <configuration> <packaging>jar</packaging> <generatePom>true</generatePom> <url>${project.distributionManagement.repository.url}</url> <artifactId>${project.artifactId}</artifactId> <groupId>${project.groupId}</groupId> <version>${project.version}</version> <file>${project.build.directory}/${project.artifactId}.jar</file> </configuration> </execution> </executions></plugin>

热点排行