Java 在 Eclipse 中创建新的 Maven 项目时显示错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25787197/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 01:07:59  来源:igfitidea点击:

Error shown when creating new Maven project in Eclipse

javaeclipsespringmaven

提问by Nithya

When I am trying to create new project on Maven in eclipse IDE ,It shows the following errors:

当我尝试在 Eclipse IDE 中的 Maven 上创建新项目时,它显示以下错误:

"Could not get the value for parameter encoding for plugin execution default-resources Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved: Failed to collect dependencies for org.apache.maven.plugins:maven-resources-plugin:jar:2.5 ()"

“无法获取插件执行默认资源插件 org.apache.maven.plugins:maven-resources-plugin:2.5 或其依赖项之一的参数编码值无法解析:无法收集org.apache 的依赖项。 maven.plugins:maven-resources-plugin:jar:2.5()"

Anyone please tell what I have to do?

任何人请告诉我必须做什么?

can anyone tell me the steps to create Spring project with Maven enabled?

谁能告诉我在启用 Maven 的情况下创建 Spring 项目的步骤?

POM.xml:

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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.spring</groupId>
  <artifactId>SpringMaven</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  <name>SpringMaven</name>
</project>

采纳答案by specialk1st

The following steps worked for me:

以下步骤对我有用:

  1. Close Eclipse.
  2. Navigate to user home directory. (For example: "C:\Users\YourUserName\.m2")
  3. Delete the "repository" folder.
  4. Re-open Eclipse.
  5. Click on the Maven project that has an issue and go to "Project" --> "Clean".
  6. Right-click on the project and go to "Maven" --> "Update Project...".
  7. Close Eclipse.
  8. Open Eclipse.
  9. Click on the project folder in the "Project Explorer" window (usually on the left).
  10. Hit the F5key a few times to Refresh your project.
  11. Done!
  1. 关闭日食。
  2. 导航到用户主目录。(例如:“C:\Users\YourUserName\.m2”)
  3. 删除“存储库”文件夹。
  4. 重新打开 Eclipse。
  5. 单击有问题的 Maven 项目,然后转到“项目”-->“清理”。
  6. 右键单击项目并转到“Maven”-->“更新项目...”。
  7. 关闭日食。
  8. 打开日食。
  9. 单击“项目资源管理器”窗口(通常在左侧)中的项目文件夹。
  10. 击中F5键几次刷新您的项目。
  11. 完毕!

These steps worked for me. If this works for you make sure to upvote, otherwise drop a comment.

这些步骤对我有用。如果这对您有用,请务必点赞,否则请发表评论。

回答by Ankit

Delete maven resource plugin jars (delete the whole folder) from this location - {user.home}.m2\repository\org\apache\maven\plugins\maven-resources-plugin and then try to rebuild again.

从此位置删除 maven 资源插件 jars(删除整个文件夹) - {user.home}.m2\repository\org\apache\maven\plugins\maven-resources-plugin 然后再次尝试重建。

回答by smwikipedia

I had similar issue. Below is my detailed error message:

我有类似的问题。下面是我的详细错误信息:

Could not get the value for parameter encoding for plugin execution default-resources Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: The following artifacts could not be resolved: org.apache.maven:maven-plugin-api:jar:2.0.6, org.apache.maven:maven-project:jar:2.0.6, org.apache.maven:maven-profile:jar:2.0.6, org.apache.maven:maven-artifact-manager:jar:2.0.6, org.apache.maven:maven-plugin-registry:jar:2.0.6, org.apache.maven:maven-core:jar:2.0.6, org.apache.maven:maven-plugin-parameter-documenter:jar:2.0.6, org.apache.maven:maven-repository-metadata:jar:2.0.6, org.apache.maven:maven-error-diagnostics:jar:2.0.6, org.apache.maven:maven-plugin-descriptor:jar:2.0.6, classworlds:classworlds:jar:1.1, org.apache.maven:maven-artifact:jar:2.0.6, org.apache.maven:maven-settings:jar:2.0.6, org.apache.maven:maven-model:jar:2.0.6, org.apache.maven:maven-monitor:jar:2.0.6: Failure to transfer org.apache.maven:maven-plugin-api:jar:2.0.6 from https://repo.maven.apache.org/maven2was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.maven:maven-plugin-api:jar:2.0.6 from/to central (https://repo.maven.apache.org/maven2): connect timed out

无法获取插件执行的参数编码值 default-resources Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 或其依赖项之一无法解析:无法解析以下工件: org.apache.maven:maven-plugin-api:jar:2.0.6, org.apache.maven:maven-project:jar:2.0.6, org.apache.maven:maven-profile:jar:2.0.6 , org.apache.maven:maven-artifact-manager:jar:2.0.6, org.apache.maven:maven-plugin-registry:jar:2.0.6, org.apache.maven:maven-core:jar:2.0 .6, org.apache.maven:maven-plugin-parameter-documenter:jar:2.0.6, org.apache.maven:maven-repository-metadata:jar:2.0.6, org.apache.maven:maven-error -diagnostics:jar:2.0.6, org.apache.maven:maven-plugin-descriptor:jar:2.0.6, classworlds:classworlds:jar:1.1, org.apache.maven:maven-artifact:jar:2.0.6 , org.apache.maven:maven-settings:jar:2.0.6, org.apache.maven:maven-model:jar:2.0.6, org.apache.maven:maven-monitor:jar:2.0.6: 失败从https://repo.maven.apache.org/maven2传输 org.apache.maven:maven-plugin-api:jar:2.0.6 已缓存在本地存储库中,直到 Central 的更新间隔已过或强制更新,才会重新尝试解析。原始错误:无法传输工件 org.apache.maven:maven-plugin-api:jar:2.0.6 from/to central ( https://repo.maven.apache.org/maven2):连接超时

From the first look, it seems the connection to the central repository failed. But actually it turns out something is f**ked up in my local repository.

乍一看,似乎与中央存储库的连接失败了。但实际上,我的local repository.

Rather than spend time to figuring out what's wrong with my 10Glocal repository, I use an empty folder as the new local repository.

我没有花时间找出我的10G本地存储库出了什么问题,而是使用一个空文件夹作为新的本地存储库。

And error is gone.

错误消失了。

This is not a solution. This is just a workaround.

这不是解决方案。这只是一种解决方法。

I think maven is not robust enough when local repository gets big. And the misleading error message has wasted me a lot of time to check network or proxy issue. Hope it can save other souls some time.

我认为当本地存储库变大时,maven 不够健壮。误导性的错误信息浪费了我很多时间来检查网络或代理问题。希望它可以在一段时间内拯救其他灵魂。

BTW: Apache Maven Cookbook 2015is a very good book for Maven starters.

顺便说一句:Apache Maven Cookbook 2015是一本非常适合 Maven 初学者的书。

ADD 1

添加 1

The chosen answer did essentially similar things to mine.

所选择的答案与我的答案基本相似。

回答by user6833385

  1. close eclipse, delete the .m2 folder
  2. go to "https://repo.maven.apache.org/maven2" and download the certificate and install certificate by using "keytool" for more detail google it.
  3. open eclipse and update existing maven project.
  4. Now try creating maven project, it should be fine now.
  1. 关闭eclipse,删除.m2文件夹
  2. 转到“ https://repo.maven.apache.org/maven2”并使用“keytool”下载证书并安装证书以获取更多详细信息。
  3. 打开 Eclipse 并更新现有的 Maven 项目。
  4. 现在尝试创建 maven 项目,现在应该没问题了。