原文鏈接:https://www.cnblogs.com/lianshan/p/7358966.html
背景:
如果你想在項maven生命周期內,運行一段java代碼,或者一段獨立的程序,或者說我們所指的預執行,初始化某些值,生成某些不能預先生成的文件。
那么這樣我們就可以使用exec-maven-plugin進行程序的預執行,生成相關文件。
具體配置如下:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<goals>
<goal>java</goal> <!-- java還是exec-->
</goals>
<phase>compile</phase> <!--生命周期-->
</execution>
</executions>
<configuration>
<mainClass>com.sf.ucmp2.doclet.Main</mainClass> <!--程序入口,主類名稱-->
<arguments>
<argument>-encoding</argument> <!--相關參數-->
<argument>utf-8</argument>
</arguments>
<classpathScope>compile</classpathScope>
</configuration>
</plugin>
