使用maven运行Java main的2种方式

来源:互联网 发布:python统计词频 编辑:程序博客网 时间:2024/05/16 12:36

一:直接在命令行运行

mvn clean compile exec:java -Dexec.mainClass="com.demo.App" -Dexec.args="aaa bbb"

二:使用插件运行

<plugin><groupId>org.codehaus.mojo</groupId><artifactId>exec-maven-plugin</artifactId><version>1.4.0</version><executions><execution><phase>test</phase><goals><goal>java</goal></goals><configuration><mainClass>com.demo.App</mainClass><arguments><argument>11111111</argument><argument>22222222</argument></arguments></configuration></execution></executions></plugin>

配置好插件后,执行mvn test 即可执行main方法

7 0