[英]What is the default lifecycle in Maven
我正在嘗試學習maven,並通過Maven docs的下面的聲明
有三個內置的構建生命周期: 默認,清理和站點 。 默認生命周期處理項目部署,清潔生命周期處理項目清理,而站點生命周期處理項目站點文檔的創建。
還有另一個聲明說:
default(或build):這用於構建應用程序。
我能夠成功運行命令mvn clean
& mvn site
。 但是當我運行以下命令時,我得到例外:
命令:
mvn default
& mvn build
錯誤詳情:
[WARNING]
[WARNING] Some problems were encountered while building the effective model for org.hibernate.tutorials:hibernate-tutorial:jar:1.0.0-SNAPSHOT
[WARNING] The expression ${artifactId} is deprecated. Please use ${project.artifactId} instead.
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[ERROR] Unknown lifecycle phase "build". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-site, site, post-site, site-deploy, pre-clean, clean, post-clean. -> [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/LifecyclePhaseNotFoundException
你還沒有讀完全部內容:
要做所有這些,您只需要調用要執行的最后一個構建階段,在這種情況下,部署:
mvn deploy
實際上,默認生命周期包含階段(按此順序):
validate - validate the project is correct and all necessary information is available compile - compile the source code of the project test - test the compiled source code using a suitable unit testing framework. These tests should not require the code be packaged or deployed package - take the compiled code and package it in its distributable format, such as a JAR. integration-test - process and deploy the package if necessary into an environment where integration tests can be run verify - run any checks to verify the package is valid and meets quality criteria install - install the package into the local repository, for use as a dependency in other projects locally deploy - done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects.
並且您需要在命令行中指定要執行的最后一步,它將執行在此之前和此之前的所有步驟。 例如,如果你這樣做:
mvn install
它將執行:驗證,編譯,測試,打包,集成測試,驗證和安裝(以及其他一些階段,請參閱完整列表 )。
對於第一個警告 - 檢查您的pom以查看您是否使用表達式${artifactId}
,它已被棄用,而應該是${project.artifactId}
對於錯誤 - 構建不是maven生命周期階段。 您需要執行mvn clean install
來構建項目。 這些是基本的maven功能,並且有很好的文檔記錄
建議您閱讀本教程,這將使您開始使用maven(以及更多)。
http://www.tutorialspoint.com/maven/maven_build_life_cycle.htm
來自同一個鏈接 -
典型的Maven構建生命周期包含以下幾個階段:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.