【问题标题】:Maven plugins are not downloading or resolving when I create a new project当我创建一个新项目时,Maven 插件没有下载或解析
【发布时间】: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

错误窗口是这样的:-

有关错误的确切信息,请参阅此屏幕截图。

Screenshot attached

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>

目前尝试过的解决方案:-

  1. 使用 help > install a new software 选项安装 maven
  2. 尝试使用 cmd 进行 mvn 安装
  3. 尝试在 setting.xml 文件中取消注释代理标记
  4. 在 settings.xml 文件中的代理标记中尝试使用“https”而不是“http”
  5. 尝试重新安装 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

标签: java maven


【解决方案1】:

给定的 ERORR 是默认目标的原因。

错误没有为此构建指定目标。您必须以 : 或 :[:]: 格式指定有效的生命周期阶段或目标。

分辨率:

在运行配置中为 maven 构建指定任何目标,例如清除、编译、安装、打包。

安装 ...

你能参考给定的步骤吗?

  • 右键单击您的项目。
  • 点击“运行方式”并选择“Maven 构建”
  • 编辑配置窗口将打开。
  • 写任何目标,但你的问题具体写“包” 在目标文本框中。
  • 点击“运行”

【讨论】:

    【解决方案2】:

    settings.xml 文件有问题,解决方法是:-

    1. 首先关闭 eclipse - 尝试在 CMD 中工作并在那里配置 maven。如果文件存在,请删除用户目录中的 setting.xml。

    2. 从官方网站下载 Maven。

    3. 将 %MVN_HOME%\bin 的路径添加到 Path env。 Windows 中的变量。

    4. 打开 CMD 并 cd 到您有 pom.xml 的文件夹。

    5. 类型:mvn 包。 6. 发布输出。

    感谢@MarkBramnik

    【讨论】:

      【解决方案3】:

      你必须指定 Maven 目标。 在 pom.xml 中,插入那个

      <build>
          <defaultGoal>install</defaultGoal>
      
      </build>
      

      我猜你的 pom.xml 中没有 defaultGoal。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-02-20
        • 1970-01-01
        • 2022-11-24
        • 2012-04-22
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多