Maven:~/.m2/settings.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"> <!-- 官网参考: http://maven.apache.org/guides/mini/guide-mirror-settings.html --> <mirrors> <mirror> <id>alimaven</id> <name>阿里云中央仓库</name> <mirrorOf>central,jcenter</mirrorOf> <url>https://maven.aliyun.com/repository/public/</url> </mirror> </mirrors> </settings>
Gradle: ~/.gradle/init.gradle
// 官网参考: https://docs.gradle.org/current/userguide/init_scripts.html#header allprojects { repositories { maven { url 'https://maven.aliyun.com/repository/gradle-plugin' } maven { url 'https://maven.aliyun.com/repository/public/' } maven { url 'https://maven.aliyun.com/repository/google' } } }
// 验证:工程文件的build.gradle加入如下任务,并运行 gradle showRepos task showRepos { doLast { repositories.each { println "repository: ${it.name} ('${it.url}')" } } }