不带参数
package com.test;
public class Test {
public static void main(String[] args) throws Exception {
System.out.println("test");
}
}
编译执行
mvn compile exec:java -Dexec.mainClass="com.test.Test"
带参数
package com.test;
import java.util.Arrays;
public class Test {
public static void main(String[] args) throws Exception {
System.out.println("args=" + Arrays.deepToString(args));
}
}
编译执行
mvn compile exec:java -Dexec.mainClass="com.test.Test" -Dexec.args="hello world test"