1.针对单个项目比较简单:
repositories { maven { url 'https://maven.aliyun.com/repository/public/' } maven { url 'https://maven.aliyun.com/repository/spring/' } mavenLocal() mavenCentral() }
针对全局项目
在GRADLE_HOME/init.d/目录下新建文件:init.gradle
allprojects { repositories { mavenLocal() maven { url 'https://maven.aliyun.com/repository/public/' } maven { url 'https://maven.aliyun.com/repository/spring/'} maven { url 'https://maven.aliyun.com/repository/google/'} maven { url 'https://maven.aliyun.com/repository/gradle-plugin/'} maven { url 'https://maven.aliyun.com/repository/spring-plugin/'} maven { url 'https://maven.aliyun.com/repository/grails-core/'} maven { url 'https://maven.aliyun.com/repository/apache-snapshots/'} mavenCentral() } }
Maven配置阿里源
【idea自带maven插件路径:C:\Program Files\JetBrains\IntelliJ IDEA 2019.1\plugins\maven\lib\maven3\conf】
C:\Users\{USER}\.m2\settings.xml
<mirrors> <mirror> <id>aliyun-public</id> <mirrorOf>*</mirrorOf> <name>aliyun public</name> <url>https://maven.aliyun.com/repository/public</url> </mirror> </mirrors>
<profile> <repositories> <repository> <id>google</id> <url>https://maven.aliyun.com/repository/google</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> <repository> <id>gradle-plugin</id> <url>https://maven.aliyun.com/repository/gradle-plugin</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> <repository> <id>spring</id> <url>https://maven.aliyun.com/repository/spring</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> <repository> <id>spring-plugin</id> <url>https://maven.aliyun.com/repository/spring-plugin</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> <repository> <id>grails-core</id> <url>https://maven.aliyun.com/repository/grails-core</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> </profile>