gradle|gradle配置阿里云镜像和插件镜像

grdle配置阿里云的镜像


在本站的demo系列基本上都用的是gradle,很少用maven了,但是用gradle的朋友们会发现,下载jar包的速度确实有点慢,因此需要配置个国内的镜像,build.gradle代码如下:
重点关注repositories配置

plugins {
id 'org.springframework.boot' version '2.2.1.RELEASE'
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
id 'java'
}

group = 'cloud.javastudy.study'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

repositories {
  //重点在这里,添加阿里云的镜像
  maven {
    url 'https://maven.aliyun.com/repository/public'
  }
mavenCentral()
}

dependencies {
  implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
  implementation 'org.springframework.boot:spring-boot-starter-web'

  testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
  }
}

test {
  useJUnitPlatform()
}

gradle添加插件的镜像配置


这块在网上的资料比较少,因为nexus做gradle插件库地址映射也比较麻烦,不过还好,用阿里云的可以配置下就可以用了
主要是修改settings.gradle,代码如下:

pluginManagement {
    repositories {
        maven { url "https://maven.aliyun.com/repository/gradle-plugin"
        }
    }
}
rootProject.name = 'demo'

DEMO 总评


在gradle逐渐取代maven的趋势下,我们要把原有的在maven上完成的操作都搬到gradle上来,如打包,上传包到服务器,上传包到本地等等,本DEMO只介绍了gradle里面配置阿里云的镜像,还有插件也配置镜像,加油吧,少年!

猜你喜欢

转载自blog.51cto.com/15082395/2645949