Maven Build在命令提示符中失败,但在Eclipse中获得构建

时间:2018-11-16 10:18:25

标签: java eclipse maven pom.xml

我正在命令提示符下使用mvn clean命令,并且构建失败。

Downloading: 
https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean- 
plugin/2.5/maven-clean-plugin-2.5.pom
[INFO] Reactor Summary:
[INFO] ABC ......................................... FAILURE [  2.226 s]
[INFO] BUILD FAILURE
[INFO] Total time: 3.098 s
[INFO] Finished at: 2018-11-16T15:10:36+05:30
[INFO] Final Memory: 12M/153M
 [ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of 
its 
 dependencies could not be resolved: Failed to read artifact descriptor for 
 org.apache.maven.plugins:maven-clean-plugin:jar:2.5: Could not transfer 
artifact 
org.apache.maven.plugins:maven-clean-plugin:pom:2.5 from/to central 
(https://repo.maven.apache.org/maven2): Received fatal alert: 
protocol_version - 
> [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] For more information about the errors and possible solutions, 
please 
read the following articles:
[ERROR] [Help 1] 
http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException

但是当我从Eclipse内部使用mvn clean命令时,它正在成功构建。

[INFO] --------------------------------------------------------------------- 
---
Downloading: 
http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean- 
plugin/2.4.1/maven-clean-plugin-2.4.1.pom
Downloaded: 
http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean- 
plugin/2.4.1/maven-clean-plugin-2.4.1.pom (5 KB at 5.2 KB/sec)
-------------------------
[INFO] BUILD SUCCESS
[INFO] Total time: 4.387s

我能看到的区别是,它在命令提示符下尝试下载maven-clean-plugin-2.5,而从eclipse成功下载了2.4.1

但是我只需要运行2.5。 谁可以帮我这个事。 谢谢。

1 个答案:

答案 0 :(得分:0)

我不知道您是否在全球范围内安装了Maven。您可以尝试全局安装Maven。遵循步骤。

  1. maven download link

  2. 下载行家
  3. 创建或导出M2_HOME =“ MAVEN ROOT LOCATION”。例如: E:\ SoftwareRepo \ building tools \ apache-maven-3.5.2

  4. 创建MAVEN bin文件夹位置或将其导出到PATH变量。例如: E:\ SoftwareRepo \ building tools \ apache-maven-3.5.2 \ bin

  5. 打开终端或cmd,然后运行 mvn --version 确认是否已安装Maven。

您可以将其与Eclipse一起使用。 然后去蚀。并设置项目。请按照以下步骤操作

  1. 导入现有的maven项目或创建一个maven项目
  2. 转到项目浏览器,然后右键单击pom.xml
  3. 然后选择运行方式maven安装。
  4. 然后是您想要的。 希望它能达到您的目的。您可以下载sample spring boot project

或者您可以从终端或cmd运行Maven项目。只需转到项目根文件夹,然后运行诸如maven clean install之类的maven任务即可。快乐编码:)

enter image description here