1. 程式人生 > >Maven 打包時遇到的坑,哭會

Maven 打包時遇到的坑,哭會

我用的是ecplise自帶的maven外掛建立的工程,jdk版本都換了,還是說沒有jre環境。
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (default-compile) on project taotao-manager-pojo: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1]

http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn -rf :spring-pojo

跳過測試階段:
mvn package -DskipTests

臨時性跳過測試程式碼的編譯:

mvn package -Dmaven.test.skip=true

maven.test.skip同時控制maven-compiler-plugin和maven-surefire-plugin兩個外掛的行為,即跳過編譯,又跳過測試。

指定測試類

mvn test -Dtest=RandomGeneratorTest
以Random開頭,Test結尾的測試類
mvn test -Dtest=Random*Test
用逗號分隔指定多個測試用例
mvn test -Dtest=ATest,BTest

指定即使沒有任何測試用例也不要報錯

test引數必須匹配至少一個測試類,否則會報錯並導致構建失敗。此時可使用以下配置來指定即使沒有任何測試用例也不要報錯。
mvn test -Dtest -DfailIfNoTests = false

也可以配置maven ,使打包時預設跳過測試用例。