命令格式: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在同級目錄