在没有私服的情况下,用中央仓库 速度超级慢,影响开发速度,并且eclipse容易卡死;
maven的 setting文件默认是中央仓库地址,国外的,速度比较慢 想换成国内的仓库地址:http://maven.aliyun.com/nexus/content/groups/public/
但是 修改了几次使用不生效,依然去 国外的中央仓库下载 jar文件
最近 新安装 开发环境,又配置了一下,还是没生效, 然后隔天来 重启机器 居然好了。
我怀疑这个事情 还是在哪里有缓存,setting.xml配置文件如下:
<?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
| The path to the local repository maven will use to store artifacts.
|
| Default: ${user.home}/.m2/repository-->
<localRepository>D:/maven</localRepository>
<mirrors>
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</mirror>
</mirrors>
</settings>
最后找到原因,修改了setting.xml的配置以后,需要重启一下elipse,才生效。
至此,问题解决;
使用gradle的时候 可以直接在build.gradle文件中配置,但是要注意顺序;
repositories {
mavenLocal()
maven { url "http://maven.aliyun.com/nexus/content/groups/public/" }
}
如果在mavenLocal()后面 maven{} 前面配置了 mavencenter();那么 还是会去 中央仓库获取jar包
所以这里就只配置mavenLocal()和 maven{} ,需要的jar如果aliyun仓库没有,他自己会去 其他仓库补充。
至此,gradle的使用aliyun仓库的问题也解决了。