maven不能下載中央庫jar問題的解決
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-clean-plugin:2.4.1: Plugin org.apache.maven.plugins:maven-clean-plugin:2.4.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.4.1
原因是從國外http://repo1.maven.org下載庫速度很慢所致,我的做法是,找到Maven安裝目錄裡的配置檔案conf,開啟settings.xml檔案,maven預設把jar下載到C盤:使用者/使用者名稱資料夾/.m2/repository,把jar下載到系統盤是一個很不安全的做法,所以我修改conf裡的setting.xml檔案,將jar存放到指定的目錄,<localRepository>D:\maven\mavenJars\repository</localRepository>。這裡需要注意的是,要把預設存放目錄那部分註釋去掉,否則這樣的修改將不會生效,到時maven還會把jars下載到C盤的m2檔案夾裡的,不要以為註釋掉就沒有影響。
其次,指定maven下載jar的來源地,在settings.xml檔案中找到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>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://maven.aliyun.com/nexus/content/groups/public/</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>
儲存,再重新建maven專案就正常了