1、首先根据项目中 gradle\wrapper\gradle-wrapper.properties 文件的 distributionUrl 属性的值
#Tue Feb 06 12:27:20 CET 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-bin.zip
2、根据 distributionUrl 对应的 gradle 的版本好,去下载相应的版本,可以通过 迅雷 或者其他国内网站下载,下载后先保存在本地,等待后续使用
3、运行 gradle build 命令进行构建
# Windows 下使用
gradlew.bat build # Linux mac 下使用
gradlew build
运行以后,提示下载时,终止掉
终止掉后,打开此文件夹 $GRADLE_USER_HOME/wrapper/dists/gradle-4.8.1-bin/e8p42vx1m7a3mz9ydmjagn6wn
橙色字体可能会和我不一样,无所谓
提示:这个文件夹大多数都在用户主目录下 .gradle//wrapper/dists/... 下
4、在进入上一步说的文件夹以后先删除所有文件,然后把第二步下载好的 zip 文件复制到此文件夹下 $GRADLE_USER_HOME/wrapper/dists/gradle-4.8.1-bin/e8p42vx1m7a3mz9ydmjagn6wn 。
5、再次执行 gradle build (注意 Windows 和 linux的命令不同),会变成如下,不需要再下载这个文件了,编译会很快通过
C:\Users\duwenlei\IdeaProjects\spring_boot_demo λ gradlew.bat build Unzipping C:\Users\duwenlei\.gradle\wrapper\dists\gradle-4.8.1-bin\e8p42vx1m7a3mz9ydmjagn6wn\gradle-4.8.1-bin.zip to C:\Users\duwenlei\.gradle\wrapper\dists\gradle-4.8.1-bin\e8p42vx1m7a3mz9ydmjagn6wnWelcome to Gradle 4.8.1!Here are the highlights of this release:- Dependency locking- Maven Publish and Ivy Publish plugins improved and marked stable- Incremental annotation processing enhancements- APIs to configure tasks at creation timeFor more details see https://docs.gradle.org/4.8.1/release-notes.html Starting a Gradle Daemon (subsequent builds will be faster)...Download http://maven.aliyun.com/nexus/content/repositories/central/org/springframework/boot/spring-boot-starter-test/2.0.6.RELEASE/spring-boot-starter-test-2.0.6.RELEASE.jar> Task :test 2018-10-25 23:34:55.551 INFO 588 --- [ Thread-5] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@413698fe: startup date [Thu Oct 25 23:34:52 CST 2018]; root of context hierarchyBUILD SUCCESSFUL in 1m 5s 5 actionable tasks: 5 executed
6、完结,可以在通过 IDEA 或者其他编码工具打开工程,跳过了慢悠悠的下载过程。