gpt4 book ai didi

java - 创建 Maven 项目,无法解析原型(prototype),连接被拒绝

转载 作者:行者123 更新时间:2023-12-03 02:19:47 24 4
gpt4 key购买 nike

我怀疑我有 Maven 代理问题。当我创建一个新项目时:

1) 文件 -> 新建 -> Maven 项目

2)我选择 archetype :在 org.apache.maven.archetypes -> ma​​ven-archetype-webapp

3)我收到此错误:

Could not resolve archetype org.apache.maven.archetypes:maven-archetype-webapp:RELEASE from any of the configured repositories.

Creating maven-archetype-webapp' has encountered a problem. Could not resolve archetype org.apache.maven.archetypes:maven-archetype-webap p:RELEASE from any of the configured repositories.

详细信息:

Could not resolve archetype org.apache.maven.archetypes:maven-archetype-webapp:RELE ASE from any of the configured repositories. Could not resolve artifact org.apache.maven.archetypes:maven-archetype-webapp:p om:RELEASE Failed to resolve version for org.apache.maven.archetypes:maven-archetype-webapp :pom:RELEASE: Could not find metadata org.apache.maven.archetypes:maven-archetype-webapp /maven-metadata.xml in local (D:\ Users\ dlefebvreVm2 \ repository) Failed to resolve version for org.apache.maven.archetypes:maven-archetype-webapp :pom:RELEASE: Could not find metadata org.apache.maven.archetypes:maven-archetype-webapp /maven-metadata.xml in local (D:\ Users\ dlefebvreVm2 \ repository)

.log文件中:

ENTRY org.eclipse.m2e.logback.appender 2 0 2015-05-18 09:30:10.373 !MESSAGE Failure to transfer org.apache.maven.archetypes:maven-archetype-webapp/maven-metadata.xml from repo.maven.apache.org/maven2 was 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 metadata org.apache.maven.archetypes:maven-archetype-webapp/maven-metadata.xml from/to central (repo.maven.apache.org/maven2): Connection refused: connect

ENTRY org.eclipse.m2e.logback.appender 2 0 2015-05-18 09:30:13.259 !MESSAGE Failure to transfer org.apache.maven.archetypes:maven-archetype-webapp/maven-metadata.xml from repo.maven.apache.org/maven2 was 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 metadata org.apache.maven.archetypes:maven-archetype-webapp/maven-metadata.xml from/to central (repo.maven.apache.org/maven2): Connection refused: connect

ENTRY org.eclipse.m2e.core 4 -1 2015-05-18 09:30:13.329 !MESSAGE Could not resolve archetype org.apache.maven.archetypes:maven-archetype-webapp:RELEASE from any of the configured repositories. !STACK 1 org.eclipse.core.runtime.CoreException: Could not resolve artifact org.apache.maven.archetypes:maven-archetype-webapp:pom:RELEASE at org.eclipse.m2e.core.internal.embedder.MavenImpl$5.call(MavenImpl.java:769) at org.eclipse.m2e.core.internal.embedder.MavenImpl$5.call(MavenImpl.java:1) at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:166) at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:109) at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:96) at org.eclipse.m2e.core.internal.embedder.MavenImpl.resolve(MavenImpl.java:736) at org.eclipse.m2e.core.internal.embedder.MavenImpl.resolve(MavenImpl.java:713) at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.resolveArchetype(ProjectConfigurationManager.java:829) at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.createArchetypeProjects0(ProjectConfigurationManager.java:743) at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager$5.call(ProjectConfigurationManager.java:719) at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager$5.call(ProjectConfigurationManager.java:1) at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:166) at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:142) at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:96) at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1348) at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.createArchetypeProjects(ProjectConfigurationManager.java:717) at org.eclipse.m2e.core.ui.internal.wizards.MavenProjectWizard$5.doCreateMavenProjects(MavenProjectWizard.java:244) at org.eclipse.m2e.core.ui.internal.wizards.AbstactCreateMavenProjectJob$1.doCreateMavenProjects(AbstactCreateMavenProjectJob.java:46) at org.eclipse.m2e.core.ui.internal.wizards.AbstractCreateMavenProjectsOperation.run(AbstractCreateMavenProjectsOperation.java:62) at org.eclipse.m2e.core.ui.internal.wizards.AbstactCreateMavenProjectJob.runInWorkspace(AbstactCreateMavenProjectJob.java:50) at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:38) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54) Contains: Failed to resolve version for org.apache.maven.archetypes:maven-archetype-webapp:pom:RELEASE: Could not find metadata org.apache.maven.archetypes:maven-archetype-webapp/maven-metadata.xml in local (D:\Users\dlefebvre.m2\repository) org.eclipse.aether.resolution.VersionResolutionException: Failed to resolve version for org.apache.maven.archetypes:maven-archetype-webapp:pom:RELEASE: Could not find metadata org.apache.maven.archetypes:maven-archetype-webapp/maven-metadata.xml in local (D:\Users\dlefebvre.m2\repository) at org.apache.maven.repository.internal.DefaultVersionResolver.resolveVersion(DefaultVersionResolver.java:312) at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:318) at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:262) at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:239) at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:295) at org.eclipse.m2e.core.internal.embedder.MavenImpl$5.call(MavenImpl.java:746) at org.eclipse.m2e.core.internal.embedder.MavenImpl$5.call(MavenImpl.java:1) at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:166) at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:109) at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:96) at org.eclipse.m2e.core.internal.embedder.MavenImpl.resolve(MavenImpl.java:736) at org.eclipse.m2e.core.internal.embedder.MavenImpl.resolve(MavenImpl.java:713) at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.resolveArchetype(ProjectConfigurationManager.java:829) at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.createArchetypeProjects0(ProjectConfigurationManager.java:743) at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager$5.call(ProjectConfigurationManager.java:719) at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager$5.call(ProjectConfigurationManager.java:1) at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:166) at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:142) at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:96) at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1348) at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.createArchetypeProjects(ProjectConfigurationManager.java:717) at org.eclipse.m2e.core.ui.internal.wizards.MavenProjectWizard$5.doCreateMavenProjects(MavenProjectWizard.java:244) at org.eclipse.m2e.core.ui.internal.wizards.AbstactCreateMavenProjectJob$1.doCreateMavenProjects(AbstactCreateMavenProjectJob.java:46) at org.eclipse.m2e.core.ui.internal.wizards.AbstractCreateMavenProjectsOperation.run(AbstractCreateMavenProjectsOperation.java:62) at org.eclipse.m2e.core.ui.internal.wizards.AbstactCreateMavenProjectJob.runInWorkspace(AbstactCreateMavenProjectJob.java:50) at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:38) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54) Caused by: org.eclipse.aether.transfer.MetadataNotFoundException: Could not find metadata org.apache.maven.archetypes:maven-archetype-webapp/maven-metadata.xml in local (D:\Users\dlefebvre.m2\repository) at org.eclipse.aether.internal.impl.DefaultMetadataResolver.resolve(DefaultMetadataResolver.java:260) at org.eclipse.aether.internal.impl.DefaultMetadataResolver.resolveMetadata(DefaultMetadataResolver.java:218) at org.apache.maven.repository.internal.DefaultVersionResolver.resolveVersion(DefaultVersionResolver.java:250) ... 26 more !SUBENTRY 1 org.eclipse.m2e.core 4 -1 2015-05-18 09:30:13.334 !MESSAGE Could not resolve artifact org.apache.maven.archetypes:maven-archetype-webapp:pom:RELEASE !SUBENTRY 2 org.eclipse.m2e.core 4 -1 2015-05-18 09:30:13.334 !MESSAGE Failed to resolve version for org.apache.maven.archetypes:maven-archetype-webapp:pom:RELEASE: Could not find metadata org.apache.maven.archetypes:maven-archetype-webapp/maven-metadata.xml in local (D:\Users\dlefebvre.m2\repository) !STACK 0 org.eclipse.aether.resolution.VersionResolutionException: Failed to resolve version for org.apache.maven.archetypes:maven-archetype-webapp:pom:RELEASE: Could not find metadata org.apache.maven.archetypes:maven-archetype-webapp/maven-metadata.xml in local (D:\Users\dlefebvre.m2\repository) at org.apache.maven.repository.internal.DefaultVersionResolver.resolveVersion(DefaultVersionResolver.java:312) at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:318) at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:262) at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:239) at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:295) at org.eclipse.m2e.core.internal.embedder.MavenImpl$5.call(MavenImpl.java:746) at org.eclipse.m2e.core.internal.embedder.MavenImpl$5.call(MavenImpl.java:1) at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:166) at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:109) at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:96) at org.eclipse.m2e.core.internal.embedder.MavenImpl.resolve(MavenImpl.java:736) at org.eclipse.m2e.core.internal.embedder.MavenImpl.resolve(MavenImpl.java:713) at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.resolveArchetype(ProjectConfigurationManager.java:829) at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.createArchetypeProjects0(ProjectConfigurationManager.java:743) at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager$5.call(ProjectConfigurationManager.java:719) at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager$5.call(ProjectConfigurationManager.java:1) at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:166) at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:142) at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:96) at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1348) at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.createArchetypeProjects(ProjectConfigurationManager.java:717) at org.eclipse.m2e.core.ui.internal.wizards.MavenProjectWizard$5.doCreateMavenProjects(MavenProjectWizard.java:244) at org.eclipse.m2e.core.ui.internal.wizards.AbstactCreateMavenProjectJob$1.doCreateMavenProjects(AbstactCreateMavenProjectJob.java:46) at org.eclipse.m2e.core.ui.internal.wizards.AbstractCreateMavenProjectsOperation.run(AbstractCreateMavenProjectsOperation.java:62) at org.eclipse.m2e.core.ui.internal.wizards.AbstactCreateMavenProjectJob.runInWorkspace(AbstactCreateMavenProjectJob.java:50) at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:38) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54) Caused by: org.eclipse.aether.transfer.MetadataNotFoundException: Could not find metadata org.apache.maven.archetypes:maven-archetype-webapp/maven-metadata.xml in local (D:\Users\dlefebvre.m2\repository) at org.eclipse.aether.internal.impl.DefaultMetadataResolver.resolve(DefaultMetadataResolver.java:260) at org.eclipse.aether.internal.impl.DefaultMetadataResolver.resolveMetadata(DefaultMetadataResolver.java:218) at org.apache.maven.repository.internal.DefaultVersionResolver.resolveVersion(DefaultVersionResolver.java:250) ... 26 more

我们可以看到问题的根源:连接被拒绝:连接

我已经这样做了:

1) 窗口 -> 首选项 -> 常规 -> 网络连接。我为 HTTP 协议(protocol)输入了手动以及代理url端口 。它之所以有效,是因为在此之前,Spring Tool Suite 不想更新。之后就没事了。

2) 窗口 -> 首选项 -> Maven -> 用户设置。在全局设置中,为空。在用户设置中,我将路径设置为settings.xml。在这个文件中,我有:

<settings>
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<host>my.proxy.fr</host>
<port>3128</port>
</proxy>
</proxies>
</settings>

在本主题中: Create a Maven project in Eclipse complains "Could not resolve archetype"通过添加远程目录 http://repo1.maven.org/maven2/archetype-catalog.xml 解决了问题。对我来说,它说目录是空的。

我的配置:Windows 7 Pro 64 位,基于 Eclipse Luna SR1 (4.4.2) 的 Spring 工具套件 3.6.4.RELEASE,Java 版本 8 Update 45,无经过身份验证的代理

为什么我无法创建新的 Maven 项目?

最佳答案

我也遇到了同样的问题,我想在某个时间你试图像我一样在没有互联网连接的情况下创建 Maven 应用程序,这就是导致这个问题的原因。因为第一次 Maven 创建一个空目录并尝试下载创建项目所需的任何内容..在您创建任何 Maven 项目之后,Maven 会一直在该目录中查找,而不从互联网上下载东西。我相信解决此问题的最简单方法是关闭 Eclipse(或 sts)并删除位于(在我的情况下)“c:/Users/myname/.m2”中的 .m2 目录。然后重新打开您正在使用的 IDE。祝你好运

关于java - 创建 Maven 项目,无法解析原型(prototype),连接被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30297947/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com