您的位置:首页 > 其它

设置Maven中央仓库 国内镜像 [本地仓库]

2017-10-18 00:50 549 查看
https://www.iteblog.com/archives/2022.html

实测可行,,

ali maven仓库

找到 .m2文件夹,新建文件settings.xml,粘贴复制以下代码

C:\Users\当前计算机用户名\.m2


<?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"> <localRepository>D:\XXXXXX\_maven_repository_</localRepository>
<!-- 本地仓库地址,可存放于非C盘 -->

<pluginGroups>

<pluginGroup>org.mortbay.jetty</pluginGroup>
</pluginGroups>

<proxies>

</proxies>

<servers>
<server>
<id>releases</id>
<username>ali</username>
<password>ali</password>
</server>
<server>
<id>Snapshots</id>
<username>ali</username>
<password>ali</password>
</server>
</servers>

<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</mirror>
<mirror>
<!--This is used to direct the public snapshots repo in the
profile below over to a different nexus group -->
<id>nexus-public-snapshots</id>
<mirrorOf>public-snapshots</mirrorOf>
<url>http://maven.aliyun.com/nexus/content/repositories/snapshots/</url>
</mirror>
</mirrors>

<profiles>
<profile>
<id>development</id>
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
<profile>
<!--this profile will allow snapshots to be searched when activated-->
<id>public-snapshots</id>
<repositories>
<repository>
<id>public-snapshots</id>
<url>http://public-snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>public-snapshots</id>
<url>http://public-snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>development</activeProfile>
<activeProfile>public-snapshots</activeProfile>
</activeProfiles>
</settings>


然后使用Maven编译你的代码,这时候Maven会从阿里云上面下载Jar依赖,速度明显要比默认的快多了!

其他Maven仓库

我们还可以设置以下的Maven仓库地址,如下:

<mirrors>
<mirror>
<id>wso2maven</id>
<name>wso2 maven</name>
<url>http://maven.wso2.org/nexus/content/groups/public/</url>
<mirrorof>central</mirrorof>
</mirror>
</mirrors>


替换上最上面阿里云Maven仓库地址即可。以下的地址也可以使用:

http://maven.wso2.org/nexus/content/groups/public/ http://jcenter.bintray.com/ http://maven.antelink.com/content/repositories/central/ http://maven.springframework.org/release/ http://maven.antelink.com/content/repositories/central/ http://mavensync.zkoss.org/maven2/ http://repository.jboss.com/maven2/ http://maven.aliyun.com/nexus/content/groups/public http://uk.maven.org/maven2/ http://repo1.maven.org/maven2/ http://maven.springframework.org/milestone http://maven.jeecg.org/nexus/content/repositories/ https://repository.apache.org/content/groups/public/ https://repository.jboss.org/nexus/content/repositories/releases/ http://repo.maven.apache.org/maven2 https://oss.sonatype.org/content/repositories http://repo.spring.io/release/ http://repo.spring.io/snapshot/[/code] 
end
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: