1、修改maven根目錄下的conf文件夾中的setting.xml文件,內容如下:
<mirrors> <mirror> <id>alimaven</id> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror> </mirrors>
之后就能享受如飛的maven下載速度。
2、maven國內鏡像(maven下載慢的解決方法)
Maven是當前流行的項目管理工具,但官方的庫在國外經常連不上,連上也下載速度很慢。國內oschina的maven服務器很早之前就關了。今天發現阿里雲的一個中央倉庫,親測可用。
<mirror> <id>alimaven</id> <mirrorOf>central</mirrorOf> <name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url> </mirror>
如下:
<?xml version="1.0" encoding="UTF-8"?> <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <mirrors> <!-- 阿里雲倉庫 --> <mirror> <id>alimaven</id> <mirrorOf>central</mirrorOf> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/repositories/central/</url> </mirror> <!-- 中央倉庫1 --> <mirror> <id>repo1</id> <mirrorOf>central</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://repo1.maven.org/maven2/</url> </mirror> <!-- 中央倉庫2 --> <mirror> <id>repo2</id> <mirrorOf>central</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://repo2.maven.org/maven2/</url> </mirror> </mirrors> </settings>
針對如上在pom.xml中配置一定不要加上作用於為provided
最后附帶上maven settings.xml中添加阿里雲的maven路徑,可以提高下載速度
<mirror> <id>nexus-aliyun</id> <mirrorOf>*</mirrorOf> <name>Nexus aliyun</name> <url>http://maven.aliyun.com/nexus/content/groups/public</url> </mirror>