Eclipse使用Maven插件创建Web项目时出错:Could not resolve archetype org.apache.maven.archetypes

问题描述:

在Eclipse下,使用Maven插件创建Web项目时出错,错误提示如下:

Eclipse使用Maven插件创建Web项目时出错:Could not resolve archetype org.apache.maven.archetypes_第1张图片


错误信息:

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

Could not resolve artifact org.apache.maven.archetypes:maven-archetype-webapp:pom:1.0

Failure to transfer org.apache.maven.archetypes:maven-archetype-webapp:pom:1.0 from https://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 artifact org.apache.maven.archetypes:maven-archetype-webapp:pom:1.0 from/to central (https://repo.maven.apache.org/maven2): Remote host closed connection during handshake

Failure to transfer org.apache.maven.archetypes:maven-archetype-webapp:pom:1.0 from https://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 artifact org.apache.maven.archetypes:maven-archetype-webapp:pom:1.0 from/to central (https://repo.maven.apache.org/maven2): Remote host closed connection during handshake


解决方案:

在Eclipse中打开“Preferences”--偏好设置窗口,在左侧列表中找到“Maven”的配置项,在展开列表之后选择“Archetypes”;

点击右侧的“Add Remote Catalog”按钮,在弹出的窗口中,在“Catalog File”输入框中输入:

http://repo1.maven.org/maven2/archetype-catalog.xml

在“Description”输入框中输入“maven remote catalog”(名字个人随意),点击“OK”按钮完成新增;继续点击“OK”按钮保存Maven设置。



在设置完毕之后,重新新建Maven项目,在弹出的窗口中,在“Catalog:”下拉框中选择刚才新建的“maven remote catalog”,然后找到“Group Id”为“org.apache.maven.archetypes”,“Artifact Id”为“maven-archetype-webapp”的选项(在这里列表选项过多,可以在“Filter”输入框中输入相应的信息进行查找),点击“Next”按钮:

Eclipse使用Maven插件创建Web项目时出错:Could not resolve archetype org.apache.maven.archetypes_第2张图片


输入项目的相关信息,点击“Finish”按钮,即可完成Web项目的新建工作:

Eclipse使用Maven插件创建Web项目时出错:Could not resolve archetype org.apache.maven.archetypes_第3张图片


在点击完“Finish”按钮之后,这时候发现Eclipse就开始从远程的库中下载构建Web项目所需要的相关东西了:

Eclipse使用Maven插件创建Web项目时出错:Could not resolve archetype org.apache.maven.archetypes_第4张图片


最后在Eclipse项目列表中发现有“Framework”项目,并在Tomcat下成功发布并可以访问,表明使用Eclipse的Maven插件新建Web项目成功了。

Eclipse使用Maven插件创建Web项目时出错:Could not resolve archetype org.apache.maven.archetypes_第5张图片



你可能感兴趣的:(java,eclipse,maven,Web)