maven生成war包的两种形式
maven生成war包的两种方式build?????plugins????????plugin??????????groupIdorg.apache.maven.pl
maven生成war包的两种方式
<build>?????<plugins>????????<plugin>??????????<groupId>org.apache.maven.plugins</groupId>??????????<artifactId>maven-dependency-plugin</artifactId>??????????<version>2.0</version>??????????<executions>?????????????<execution>????????????????<id>create-structure</id>????????????????<phase>process-resources</phase>?????????????????<goals>?????????????????????<goal>unpack</goal>??????????????????</goals>??????????????????<configuration>??????????????????????<artifactItems>?????????????????????????<artifactItem>????????????????????????????<groupId>GROUPID</groupId>?????????????????????????????<artifactId>template</artifactId>?????????????????????????</artifactItem>???????????????????</artifactItems>???????????????????<outputDirectory>???????????????????????${project.build.directory}/${assembly.name}.war????????????????????</outputDirectory>??????????????????</configuration>???????????????</execution>???????????????<execution>???????????????????<id>copy-libs</id>????????????????????<phase>process-resources</phase>?????????????????????<goals>????????????????????????<goal>copy</goal>?????????????????????</goals>?????????????????????<configuration>????????????????????????<artifactItems>???????????????????????????<artifactItem>???????????????????????????????<groupId>jdom</groupId>????????????????????????????????<artifactId>jdom</artifactId>????????????????????????????</artifactItem>??????????????????????????????????......?????????????????????????</artifactItems>????????????????????????????<outputDirectory>${project.build.directory}/${assembly.name}.war/WEB-INF/lib</outputDirectory>??????????????????????</configuration>???????????????????</execution>??????????????</executions>?????????</plugin>??????????<plugin>??????????????<groupId>org.apache.maven.plugins</groupId>??????????????<artifactId>maven-antrun-plugin</artifactId>??????????????<version>1.3</version>??????????????<executions>?????????????????<execution>????????????????????<id>copy-config</id>????????????????????<phase>process-resources</phase>????????????????????<goals>????????????????????????<goal>run</goal>?????????????????????</goals>?????????????????????<configuration>?????????????????????<tasks>?????????????????????????<copy?todir="${project.build.directory}/${assembly.name}.war">?????????????????????????????<fileset?dir="src/main/resources"?/>?????????????????????????</copy>?????????????????????????<zip?destfile="${project.build.directory}/${assembly.name}-${project.version}-war.zip">??????????????????????????????<zipfileset?dir="${project.build.directory}/${assembly.name}.war"?includes="**\*.*"??excludes="*.zip"?/>?????????????????????????</zip>?????????????????????????<copy?file="${project.build.directory}/${assembly.name}-${project.version}-war.zip"??????????????????????????????????????tofile="${project.build.directory}/${assembly.name}-${project.version}.war"?/>???????????????????????</tasks>???????????????????????</configuration>??????????????????</execution>??????????????</executions>?????????</plugin>?????????<plugin>?????????????<groupId>org.codehaus.mojo</groupId>?????????????<artifactId>build-helper-maven-plugin</artifactId>?????????????<version>1.4</version>?????????????<executions>????????????????<execution>????????????????<id>attach-artifacts</id>????????????????<phase>package</phase>???????????????????<goals>???????????????????????<goal>attach-artifact</goal>???????????????????</goals>???????????????????<configuration>????????????????????????<artifacts>???????????????????????????<artifact>???????????????????????????????<file>${project.build.directory}/${assembly.name}-${project.version}.war</file>????????????????????????????????<type>war</type>????????????????????????????</artifact>?????????????????????????</artifacts>????????????????????</configuration>?????????????????</execution>??????????????</executions>???????????</plugin>??????</plugins>??</build>??
?当然这种方式也可以用来打ear包。对于打无页面操作系统的war包,个人认为用后者更灵活,当然建立假web工程,再依赖工程,通过第一种方式同样可以达到最终的结果。看个人喜好了。