简体   繁体   English

无法在Eclipse中创建新的Maven项目

[英]Cannot create a new Maven project in eclipse

When I try to create a new Maven project, this error occurs: 当我尝试创建一个新的Maven项目时,会发生此错误:

Could not resolve archetype org.apache.maven.archetype:maven-archetype-quickstart:1.1 from any of the configured repositories. 无法从任何已配置的存储库解析原型org.apache.maven.archetype:maven-archetype-quickstart:1.1。

Additionally, I get the following message: 此外,我收到以下消息:

Could not resolve archetype org.apache.maven.archetypes:maven-archetype-quickstart:1.1 from any of the configured repositories. 无法从任何已配置的存储库解析原型org.apache.maven.archetypes:maven-archetype-quickstart:1.1。 Could not write artifact lastUpdated status /Users/vismarkjuarez/.m2/repository/org/apache/maven/archetypes/maven-archetype-quickstart/1.1/m2e-lastUpdated.properties (No such file or directory) 无法写入工件lastUpdated状态/Users/vismarkjuarez/.m2/repository/org/apache/maven/archetypes/maven-archetype-quickstart/1.1/m2e-lastUpdated.properties(无此类文件或目录)

I've tried deleting my entire .m2 folder but can't do so (cannot delete non-empty directory error), and I've already gone ahead and deleted my .m2/repository/org/apache/maven/archetypes folder, but the same error occurs. 我尝试删除整个.m2文件夹,但无法删除(无法删除非空目录错误),并且我已经删除了.m2/repository/org/apache/maven/archetypes文件夹,但是会发生相同的错误。

I had this problem and resolved this way: 我遇到了这个问题,并通过以下方式解决了:

In Eclipse , Menu Windows ->Option Preferences ->Open Maven -> User Settings Eclipse中 ,菜单Windows- > Option Preferences- > Open Maven- > User Settings

Go to address specified in Local Repository(From merged user and global settings) and delete all folders and files. 转到本地存储库中指定的地址(通过合并的用户和全局设置),然后删除所有文件夹和文件。 Now you can create your project with no problems. 现在,您可以毫无问题地创建项目。

I know that this is an old problem but still there is no accepted answer for this problem,So I'll answer it just in case somebody stumble on this problem like me. 我知道这是一个老问题,但是仍然没有针对该问题的可接受的答案,因此,如果有人像我一样偶然发现此问题,我将为您解答。

So the issue here is that maven is not downloading latest jar and pom file for the dependencies in your case arhetype. 因此,这里的问题在于,maven并未下载最新的jar和pom文件作为您的案例原型的依赖。 The thing is maven tries to download it but failed and hence inside those folders you see pom and jar file with last downloaded type.So the solution is pretty simple. 事情是maven尝试下载它,但是失败了,因此,在那些文件夹中,您会看到上次下载类型的pom和jar文件。因此,解决方案非常简单。

  1. First go inside your .m2 folder ie C/Users/username/.m2/repository 首先进入您的.m2文件夹,即C / Users / username / .m2 / repository

  2. Now delete everything inside repository folder ie org and everything inside it 现在删除存储库文件夹(即org)中的所有内容

  3. Now go to https://github.com/sofastack/sofa-rpc/pull/190/files , copy tools/ci/.travis.settings.xml . 现在转到https://github.com/sofastack/sofa-rpc/pull/190/files ,复制tools / ci / .travis.settings.xml。

  4. Now open notepad++ , create a new file,paste the above copy file and saved it as settings.xml 现在打开notepad ++,创建一个新文件,粘贴上面的复制文件并将其保存为settings.xml。

  5. Now place your settings.xml inside C/Users/username/.m2 现在将您的settings.xml放在C / Users / username / .m2中

  6. Now open eclipse :- Click Window>Preferences>Maven>User Settings 现在打开Eclipse:-单击窗口>首选项> Maven>用户设置

  7. Now browse your User Settings file and give them the path of your settings.xml ie C/Users/username/.m2/settings.xml 现在浏览您的用户设置文件,并为它们提供settings.xml的路径,即C / Users / username / .m2 / settings.xml

  8. Now Apply the changes and start again you'll see that the dependencies will now start getting downloaded instead of creating lastdownloaded files. 现在应用更改并重新开始,您将看到依赖关系现在将开始下载而不是创建上次下载的文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM