Gradle和Maven下载jar包慢解决方案

由于项目使用的Gradle搭建的之前默认配置都是从Google下载由于本机没有科学上网,下载速度可以说是龟速,以下是我的解决方案仅供参考

  1. 首先打开build.gradle文件
  2. 将文件中修改以下代码
buildscript {
    ext {
      .....版本号
    }
    repositories {
        // NOTE: You should declare only repositories that you need here
//        mavenLocal()
//        mavenCentral()
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
        maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
        maven { url 'http://maven.aliyun.com/nexus/content/repositories/google' }
        maven { url 'http://maven.aliyun.com/nexus/content/repositories/gradle-plugin' }
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

repositories {
//    mavenLocal()
//    mavenCentral()

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

然后重启项目从新build就可以体验飞速下载了

你可能感兴趣的:(工具类)