Eclipse使用Maven创建项目是报错:Could not resolve archetype org.apache.maven.archetypes:maven-archetype-quick

问题描述:

使用Eclipse自带的Maven插件创建maven项目时报错:

Could not resolve archetype org.apache.maven.archetypes:maven-archetype-quickstart:RELEASE from any of the configured repositories.
Could not resolve artifact org.apache.maven.archetypes:maven-archetype-quickstart:pom:RELEASE
Failed to resolve version for org.apache.maven.archetypes:maven-archetype-quickstart:pom:RELEASE: Could not find metadata org.apache.maven.archetypes:maven-archetype-quickstart/maven-metadata.xml in local (C:\Users\Smith\.m2\repository)
Failed to resolve version for org.apache.maven.archetypes:maven-archetype-quickstart:pom:RELEASE: Could not find metadata org.apache.maven.archetypes:maven-archetype-quickstart/maven-metadata.xml in local (C:\Users\Smith\.m2\repository)


解决方案:

在Eclipse Maven配置中添加新的Catalog配置:

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

 如下图:



接下来在使用刚添加的catalog创建maven项目:

      

 这个时候就可以看到Eclipse联网下载了:

     
这个时候看一下是不是创建成功了


如果还是不能创建或者问题没有解决可以安装下面的方法:

1.删除maven已经下载的文件路径:.m2\repository\org\apache\maven

删除之后再试下,这时候如果看到有进度,只需要耐心等待就行了


How does the Archetype Plugin know about archetypes?

Knowledge about archetypes is stored in catalogs.

The catalogs are xml files: see the reference documentation.

The Archetype Plugin comes bundled with an internal catalog. This one is used by default.

The Archetype Plugin can use catalogs from local filesystem and from HTTP connections.

Catalog file explained

A catalog is an xml file with such content:


  
    
[1]    org.appfuse.archetypes
[2]    appfuse-basic-jsf
[3]    2.0
[4]    http://static.appfuse.org/releases
[5]    AppFuse archetype for creating a web application with Hibernate, Spring and JSF
    
    ...
  
  1. The groupId of the archetype. REQUIRED
  2. The artifactId of the archetype. REQUIRED
  3. The version of the archetype. RELEASE is a valid version. REQUIRED
  4. The repository where to find the archetype. OPTIONAL. When omitted, the archetype is searched for in the repository where the catalog comes from.
  5. The description of the archetype. OPTIONAL

Archetype selection explained

During the creation of a project from an archetype, the Archetype Plugin asks the user to choose an archetype from a list containing the archetypes from each of the provided catalogs (yes, there may be many).

For each archetype in the list, the Archetype Plugin shows a line like:

1: internal -> appfuse-basic-jsf (AppFuse archetype for creating a web application with Hibernate, Spring and JSF)
  • 1: The index of the archetype in the aggregated list (starting from 1).
  • internal The name of the catalog where the archetype originates from.
  • appfuse-basic-jsf The artifactId of the archetype.
  • (AppFuse archetype...) The description of the archetype as found in the catalog.

Creating a catalog file

At the end of the create-from-project behaviour, the Archetype Plugin installs/deploys the archetype, and updates the local/remote catalog.

The crawl-repository goal is used to create a catalog file by crawling a Maven repository located in the filesystem.

Location of catalog files

The Archetype Plugin knows by default about its internal catalog. It also knows about the local and remote catalogs.

local represents the ~/.m2/archetype-catalog.xml catalog file.

remote represents the http://repo.maven.apache.org/maven2/archetype-catalog.xml catalog file.

The Archetype Plugin can also read catalogs from filesystem/HTTP by providing the path/URL of a catalog file or of a directory containing an archetype-catalog.xml file.







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