Maven报错:No goals have been specified for this build

发布时间 2023-10-23 09:51:08作者: 王又又的锅

使用jenkins从gitlab上拉项目并使用maven进行构建(demo在ide测试正常运行)结果build失败,进入到jenkins容器中手动maven报同样的错误

错误信息:

[ERROR] No goals have been specified for this 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-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [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:
image

解决办法:

在项目pom.xml文件中的标签之间添加
<defaultGoal>compile</defaultGoal>

image

image

参考:链接