【发布时间】:2020-06-02 04:34:58
【问题描述】:
我对 maven 非常陌生,即将开始使用 maven 学习 spring,但是当我在 eclipse 中使用 maven 创建我的第一个项目时,发生了这个错误,我认为 maven 插件没有被下载。我已经尝试了 stackoverflow 的几种解决方案,但都没有奏效。
控制台窗口类似于:-
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.097 s
[INFO] Finished at: 2020-06-01T21:17:39-07:00
[INFO] ------------------------------------------------------------------------
[ERROR] No goals have been specified for this 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-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:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoGoalSpecifiedException
错误窗口是这样的:-
有关错误的确切信息,请参阅此屏幕截图。
POM.xml 文件
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.anuragr07</groupId>
<artifactId>springpractice</artifactId>
<version>0.0.1-SNAPSHOT</version>
</project>
目前尝试过的解决方案:-
- 使用 help > install a new software 选项安装 maven
- 尝试使用 cmd 进行 mvn 安装
- 尝试在 setting.xml 文件中取消注释代理标记
- 在 settings.xml 文件中的代理标记中尝试使用“https”而不是“http”
- 尝试重新安装 eclipse
也许还有更多……
mvn打包后
E:\Workspace\springpractice>mvn package
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------< com.anuragr07:springpractice >--------------------
[INFO] Building springpractice 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.6/maven-resources-plugin-2.6.pom
**Downloaded all the plugins**
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 20.831 s
[INFO] Finished at: 2020-06-01T23:52:35-07:00
[INFO] ------------------------------------------------------------------------
我真的很沮丧,并在过去 24 小时内寻找解决方案。请帮我解决这个问题。
谢谢!
【问题讨论】:
-
您能否分享您的
pom.xml,您的 pom 文件可能有问题,因为错误消息显示没有为构建指定目标。 @Anurag Rawal -
是的,我已经分享过了。你能检查一下吗。 @Ananthapadmanabhan
-
构建失败,因为您没有在 pom 文件中提供任何
build目标。 -
尝试以下操作。 1.首先关闭eclipse - 尝试在CMD中工作并在那里配置maven。如果文件存在,请删除用户目录中的 setting.xml。 2.从官网下载Maven。 3. 将 %MVN_HOME%\bin 的路径添加到 Path env。 windows中的变量。 4. 打开 CMD 并 cd 到您有 pom.xml 的文件夹。 5.类型:mvn包。 6. 发布输出。
-
这能回答你的问题吗? specifying goal in pom.xml