gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:09:34 28 4
gpt4 key购买 nike

我正在尝试学习 Maven,并通过 Maven docs 中的以下声明进行学习

There are three built-in build lifecycles: default, clean and site. The default lifecycle handles your project deployment, the clean lifecycle handles project cleaning, while the site lifecycle handles the creation of your project's site documentation.

还有另一条声明说:

default (or build):This is used to build the application.

我能够成功运行命令 mvn cleanmvn 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

最佳答案

你还没有读完:

To do all those, you only need to call the last build phase to be executed, in this case, deploy:

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

它将执行:验证、编译、测试、打包、集成测试、验证和安装(以及其他一些阶段,请参阅 complete list)。

关于java - Maven 中的默认生命周期是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30716406/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com