错误
在使用Eclipse创建Java Maven项目的时候,报错如下:
Could not resolve archetype org.apache.maven.archetypes:maven-archetype-quickstart:1.1 from any of the configured repositories. Could not resolve artifact org.apache.maven.archetypes:maven-archetype-quickstart:jar:1.1 Failure to transfer org.apache.maven.archetypes:maven-archetype-quickstart:jar:1.1 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-quickstart:jar:1.1 from/to central (https://repo.maven.apache.org/maven2): repo.maven.apache.org Failure to transfer org.apache.maven.archetypes:maven-archetype-quickstart:jar:1.1 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-quickstart:jar:1.1 from/to central (https://repo.maven.apache.org/maven2): repo.maven.apache.org
解决办法
Window > Preferences –Maven
- 确保Eclipse配置了Maven(或者至少使用了Eclipse自带的Maven-不推荐)
- 设置settings.xml
设置Archetypes
Catalog File: http://repo1.maven.org/maven2/archetype-catalog.xml
Description: maven catalog
解决之后,就可以新建Maven Project了。
新建 Maven Project
File –New —- Maven Project
每一个骨架都会建相应的目录结构和一些通用文件,最常用的是maven-archetype-quickstart和maven-archetype-webapp骨架。
maven-archetype-quickstart骨架是用来创建一个Java Project,
maven-archetype-webapp骨架则是用来创建一个JavaWeb Project。