gradle配置国内阿里云镜像

gradle-wrapper.properties:指定Gradle版本

 

#Tue Dec 22 10:24:48 CST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip

  

 

对单个项目生效,在项目中的build.gradle修改内容

 

plugins {
    id 'org.springframework.boot' version '2.4.1'
    id 'java'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'

repositories {
    maven { url 'http://maven.aliyun.com/nexus/content/groups/public/'}
    maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter'}
}

dependencies {
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-parent', version: '2.3.0.RELEASE', ext: 'pom'
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '2.3.0.RELEASE'

}




test {
    useJUnitPlatform()
}

对所有项目起作用

在USER_HOME/.gradle/下创建init.gradle文件

allprojects{
repositories {
def ALIYUN_REPOSITORY_URL = 'http://maven.aliyun.com/nexus/content/groups/public'
def ALIYUN_JCENTER_URL = 'http://maven.aliyun.com/nexus/content/repositories/jcenter'
all { ArtifactRepository repo ->
if(repo instanceof MavenArtifactRepository){
def url = repo.url.toString()
if (url.startsWith('https://repo1.maven.org/maven2')) {
project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_REPOSITORY_URL."
remove repo
}
if (url.startsWith('https://jcenter.bintray.com/')) {
project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_JCENTER_URL."
remove repo
}
}
}
maven {
url ALIYUN_REPOSITORY_URL
url ALIYUN_JCENTER_URL
}
}
}

idea中新建springboot项目访问失败解决: 

setting->http proxy->Auto-de

posted @ 2019-08-31 08:55  洞玄巅峰  阅读(33993)  评论(0编辑  收藏  举报