Maven中的默认生命周期是什么

我正在尝试学习maven,并通过Maven docs的下面的声明

有三个内置的构建生命周期: 默认,清理和站点 。 默认生命周期处理项目部署,清洁生命周期处理项目清理,而站点生命周期处理项目站点文档的创建。

还有另一个声明说:

default(或build):这用于构建应用程序。

我能够成功运行命令mvn cleanmvn site 。 但是当我运行以下命令时,我得到例外:

命令:

mvn defaultmvn 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 : or :[:]:. 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 

它将执行:validation,编译,测试,打包,集成测试,validation和安装(以及其他一些阶段,请参阅完整列表 )。

对于第一个警告 – 检查您的pom以查看您是否使用表达式${artifactId} ,它已被弃用,而应该是${project.artifactId}

对于错误 – 构建不是maven生命周期阶段。 您需要执行mvn clean install来构建项目。 这些是基本的mavenfunction,并且有很好的文档记录

建议您阅读本教程,这将使您开始使用maven(以及更多)。

http://www.tutorialspoint.com/maven/maven_build_life_cycle.htm

来自同一个链接 –

典型的Maven构建生命周期包含以下几个阶段:

  1. prepare-resources:可以在此阶段自定义资源复制。
  2. 编译:源代码编译在此阶段完成。
  3. package:此阶段创建JOM / WAR包,如POM.xml中的包装所述。
  4. 安装:此阶段将软件包安装在本地/远程maven存储库中。