maven命令行执行Main函数

不带参数

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" 

猜你喜欢

转载自blog.csdn.net/k3108001263/article/details/83692555
今日推荐