Maven報錯:maven-archetype-webapp:RELEASE from any of the configured repositories

今天學習maven,在控制檯下新建maven項目沒有問題,可是在STS(eclipse)下建立maven項目總是報錯,鬱悶死了:web

----------------------------------------------------apache

錯誤信息:Could not resolve archetype org.apache.maven.archetypes:maven-archetype-webapp:RELEASE from any of the configured repositories.
Could not resolve artifact
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 (F:\maven\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 (F:\maven\repository)app

----------------------------------------------------框架

遇到問題,就是baidu/google查找解決方法,惋惜網上不少人提到的方法試了都不行,鬱悶了好幾個小時,最後找到問題緣由以下:eclipse

 

以上報錯的緣由是:在settings.xml 文件中 mirrors出了問題。默認maven3.1.0安裝目錄下的conf目錄下的setting.xml配置文件中的mirrors配置是這樣的:webapp

 

Xml代碼 複製代碼  收藏代碼
  1. <mirrors>  
  2.   <!-- mirror   
  3.    | Specifies a repository mirror site to use instead of a given repository. The repository that   
  4.    | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used   
  5.    | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.   
  6.    |   
  7.   <mirror>  
  8.     <id>mirrorId</id>  
  9.     <mirrorOf>repositoryId</mirrorOf>  
  10.     <name>Human Readable Name for this Mirror.</name>  
  11.     <url>http://my.repository.com/repo/path</url>  
  12.   </mirror>  
  13.    -->  
  14. </mirrors>  
  <mirrors>
    <!-- mirror
     | Specifies a repository mirror site to use instead of a given repository. The repository that
     | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
     | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
     |
    <mirror>
      <id>mirrorId</id>
      <mirrorOf>repositoryId</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://my.repository.com/repo/path</url>
    </mirror>
     -->
  </mirrors>

 

我也不是很清楚爲何就是不行(猜想是maven默認的internet倉庫裏的文件不全,因此就添加了你們用得最多的maven的internet倉庫之一:lbiblio,基本全部的開源的框架的jar文件都有提供),而後在setting.xml配置文件上面我添加了一個新的mirror,添加後以下:maven

 

Xml代碼 複製代碼  收藏代碼
  1. <mirrors>  
  2.   <!-- mirror   
  3.    | Specifies a repository mirror site to use instead of a given repository. The repository that   
  4.    | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used   
  5.    | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.   
  6.    |   
  7.   <mirror>  
  8.     <id>mirrorId</id>  
  9.     <mirrorOf>repositoryId</mirrorOf>  
  10.     <name>Human Readable Name for this Mirror.</name>  
  11.     <url>http://my.repository.com/repo/path</url>  
  12.   </mirror>  
  13.    -->  
  14.    <!--如下是新增長上去的-->  
  15.    <mirror>    
  16.       <id>ibiblio.org</id>    
  17.       <name>ibiblio Mirror of http://repo1.maven.org/maven2/</name>    
  18.       <url>http://mirrors.ibiblio.org/pub/mirrors/maven2</url>    
  19.       <mirrorOf>central</mirrorOf>    
  20.    </mirror>    
  21.   
  22. </mirrors>  
  <mirrors>
    <!-- mirror
     | Specifies a repository mirror site to use instead of a given repository. The repository that
     | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
     | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
     |
    <mirror>
      <id>mirrorId</id>
      <mirrorOf>repositoryId</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://my.repository.com/repo/path</url>
    </mirror>
     -->
     <!--如下是新增長上去的-->
     <mirror> 
        <id>ibiblio.org</id> 
        <name>ibiblio Mirror of http://repo1.maven.org/maven2/</name> 
        <url>http://mirrors.ibiblio.org/pub/mirrors/maven2</url> 
        <mirrorOf>central</mirrorOf> 
     </mirror> 

  </mirrors>

就只是修改了setting.xml配置文件上的這個地方,而後在控制檯下我從新輸入:學習

mvn help:systemthis

回車,就能夠看到從新下載了好多的jar包文件。google

等下載完成後,再在eclipse新建maven項目就正常了。

相關文章
相關標籤/搜索