1. 程式人生 > >maven命令列執行Main函式

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"