clean:表示將你上一次編譯生成的一些文件刪除
test:表示只執行測試代碼
>mvn clean test -Dtest=[ClassName]
運行測試類中指定的方法:這個需要maven-surefire-plugin 2.7.3以上的版本才能支持
>mvn clean test -Dtest=[ClassName]#[MethodName]
//MethodName為要運行的方法名,支持*通配符
例如:
>mvn test -Dtest=MyClassTest#*test*
mvn clean assembly:assembly 生產jar包,在target文件夾下面,在pom.xml中添加下面的插件
可用 java -jar target/xxx.jar main函數參數列表的形式 運行jar包
<build> <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <finalName>打包后生成的jar包的名字</finalName> <appendAssemblyId>false</appendAssemblyId> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> <archive> <manifest> <mainClass>jar包的入口,也就是想要調用的main函數所在的包</mainClass> </manifest> </archive> </configuration> <executions> <execution> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> </plugins> </build>