maven中常用的plugin总结
命令格式:mvn [plugin-name]:[goal-name]
maven-clean-plugin:清除当前工程下的target目录
maven-resources-plugin:
将项目需要的配置文件拷贝到指定目录,一般在调用compile插件的时候被先执行
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>copy-resources</id>
<!-- 在default生命周期的 validate阶段就执行resources插件的copy-resources目标 -->
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<!-- 指定resources插件处理资源文件到哪个目录下 -->
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
<!-- 也可以用下面这样的方式(指定相对url的方式指定outputDirectory) <outputDirectory>target/classes</outputDirectory> -->
<!-- 待处理的资源定义 -->
<resources>
<resource>
<!-- 指定resources插件处理哪个目录下的资源文件 -->
<directory>src/main/${deploy.env}/applicationContext.xml</directory>
<!-- 指定不需要处理的资源 <excludes> <exclude>WEB-INF/*.*</exclude> </excludes> -->
<!-- 是否对待处理的资源开启过滤模式 (resources插件的copy-resources目标也有资源过滤的功能,这里配置的
这个功能的效果跟<build><resources><resource>下配置的资源过滤是一样的,只不过可能执行的阶段不一样, 这里执行的阶段是插件指定的validate阶段,<build><resources><resource>下的配置将是在resources插件的resources目标执行时起作用(在process-resources阶段)) -->
<filtering>false</filtering>
</resource>
</resources>
</configuration>
<inherited></inherited>
</execution>
</executions>
</plugin>
maven-compiler-plugin:
先执行resources插件,再将src\main\java下的java文件编译成class字节码文件,输出到target\classes目录下
maven-jar-plugin:
把class文件、配置文件打成一个jar包或war包。需要建立lib目录存放依赖包,且jar和lib在同级目录

浙公网安备 33010602011771号