maven打包classes为jar
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.5</version> <configuration> <encoding>UTF-8</encoding> </configuration> <executions> <!-- 定义在prepare-package时将classes中的代码目录打成jar --> <execution> <phase>prepare-package</phase> <goals> <goal>jar</goal> </goals> <configuration> <classesDirectory>${project.basedir}/target/classes</classesDirectory> <finalName>${project.artifactId}</finalName> <outputDirectory>${project.basedir}/target/${project.artifactId}-${project.version}/WEB-INF/lib</outputDirectory> <includes> <include>com/**</include> <include>struts2InAction/**</include> <include>thinkingInJava/**</include> </includes> </configuration> </execution> <!-- 定义execution,设置id为 default-jar,同默认配置的id,在package时过滤掉classes的部分目录 --> <!-- <execution> <id>default-jar</id> <phase>package</phase> <goals> <goal>jar</goal> </goals> <configuration> <classesDirectory>${project.basedir}/target/classes</classesDirectory> <excludes> <exclude>com/</exclude> <exclude>struts2InAction/</exclude> <exclude>thinkingInJava/</exclude> </excludes> </configuration> </execution> --> </executions> </plugin>
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.4</version> <configuration> <!-- http://maven.apache.org/plugins/maven-war-plugin/faq.html#attached --> <archiveClasses>true</archiveClasses> <!-- <packagingExcludes> WEB-INF/lib/commons-logging-*.jar, %regex[WEB-INF/lib/log4j-(?!over-slf4j).*.jar] </packagingExcludes> --> </configuration> </plugin>