Problem

When we build spring boot applications with gradle, sometimes we get this error :

A problem occurred configuring root project 'spring-boot-23'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not download spring-boot-loader-tools.jar (org.springframework.boot:spring-boot-loader-tools:2.3.2.RELEASE)
      > Could not get resource 'https://plugins.gradle.org/m2/org/springframework/boot/spring-boot-loader-tools/2.3.2.RELEASE/spring-boot-loader-tools-2.3.2.RELEASE.jar'.
         > Could not GET 'https://d29vzk4ow07wi7.cloudfront.net/9a67d3ed181df57bb2ef7892f25419a7c2e6336f488e38a477a51ae05b1c5c6f?response-content-disposition=attachment%3Bfilename%3D%22spring-boot-loader-tools-2.3.2.RELEASE.jar%22&Policy=eyJTdGF0ZW1lbnQiOiBbeyJSZXNvdXJjZSI6Imh0dHAqOi8vZDI5dnprNG93MDd3aTcuY2xvdWRmcm9udC5uZXQvOWE2N2QzZWQxODFkZjU3YmIyZWY3ODkyZjI1NDE5YTdjMmU2MzM2ZjQ4OGUzOGE0NzdhNTFhZTA1YjFjNWM2Zj9yZXNwb25zZS1jb250ZW50LWRpc3Bvc2l0aW9uPWF0dGFjaG1lbnQlM0JmaWxlbmFtZSUzRCUyMnNwcmluZy1ib290LWxvYWRlci10b29scy0yLjMuMi5SRUxFQVNFLmphciUyMiIsIkNvbmRpdGlvbiI6eyJEYXRlTGVzc1RoYW4iOnsiQVdTOkVwb2NoVGltZSI6MTYwNTE3MTE0MH0sIklwQWRkcmVzcyI6eyJBV1M6U291cmNlSXAiOiIwLjAuMC4wLzAifX19XX0_&Signature=fnvh-KaJpqOZMIe3HV9Dtfet0wCb~SFK-28DKejRb8y7UmNfXEADCnyjMG2kZ~Z95rEvdCBnHuaIyqlBcx6O5aEbISLbHp11X-Oerjl2~37nEtFDxHce6jyHH5Cb0J5z4RjOCllotMw2Qk7bgrZ4RUSjoxGS1XT03HNcxY8N5SG3P8BCmmK4fDUi4BRTrGNFnWVq47ljZJvmONbC0EXkG7hwmjIw4bPpjS8YaqE-g4lna5D1S8heEJKoNoNPga8NtXZjYap5OJufhKuALTL6oqzZUFiTu2i3WL8vQN-MwGMfFUMN4DcLdBUzPcBsNBOqpLj77OL~XeKiHUq~c2q2dQ__&Key-Pair-Id=APKAIFKFWOMXM2UMTSFA'.
            > Read timed out
   > Could not download spring-core.jar (org.springframework:spring-core:5.2.8.RELEASE)
      > Could not get resource 'https://plugins.gradle.org/m2/org/springframework/spring-core/5.2.8.RELEASE/spring-core-5.2.8.RELEASE.jar'.
         > Could not GET 'https://d29vzk4ow07wi7.cloudfront.net/fad4318d5a6850962d1975df6368b5050abb44d8b52f561783587da09bfcee7a?response-content-disposition=attachment%3Bfilename%3D%22spring-core-5.2.8.RELEASE.jar%22&Policy=eyJTdGF0ZW1lbnQiOiBbeyJSZXNvdXJjZSI6Imh0dHAqOi8vZDI5dnprNG93MDd3aTcuY2xvdWRmcm9udC5uZXQvZmFkNDMxOGQ1YTY4NTA5NjJkMTk3NWRmNjM2OGI1MDUwYWJiNDRkOGI1MmY1NjE3ODM1ODdkYTA5YmZjZWU3YT9yZXNwb25zZS1jb250ZW50LWRpc3Bvc2l0aW9uPWF0dGFjaG1lbnQlM0JmaWxlbmFtZSUzRCUyMnNwcmluZy1jb3JlLTUuMi44LlJFTEVBU0UuamFyJTIyIiwiQ29uZGl0aW9uIjp7IkRhdGVMZXNzVGhhbiI6eyJBV1M6RXBvY2hUaW1lIjoxNjA1MTcxMDcwfSwiSXBBZGRyZXNzIjp7IkFXUzpTb3VyY2VJcCI6IjAuMC4wLjAvMCJ9fX1dfQ__&Signature=O5H2E5e7p~5EwVHxgjP9qx3pcnQZzR0r4LUNrYGpkwGMuxGgG0~sZexXmu-7io8WlD-RT0sySsT0Z3A7IDC~i8rFFxVo0DTDVwK5d4JliCuodTr42pXqc42NMCS1iS20aTsFLFmV9AURBiwhzWF5m~GO-Vnhy-Y4MImvHHBNZK13b85V-IAp3BWye-F1PETSnmsJDWJNBgXU4FHpe8rEq-aWetcS5ihYv9lKYWAwGt10djTEcHgEoqq5rU-PWHjI1PSX0dv93cSOfAxDU~u2fqq-Nu8vD6RDPGgTVD6RO-PcaW-6aV5DUJZVJV4YIzJPMA5HbHyArmkC2GuKnQRH6w__&Key-Pair-Id=APKAIFKFWOMXM2UMTSFA'.
            > Read timed out
   > Could not download jackson-databind.jar (com.fasterxml.jackson.core:jackson-databind:2.11.1)
      > Could not get resource 'https://plugins.gradle.org/m2/com/fasterxml/jackson/core/jackson-databind/2.11.1/jackson-databind-2.11.1.jar'.
         > Could not GET 'https://d29vzk4ow07wi7.cloudfront.net/b486be39d9ff4ae8bc7782792f2ea70f3a7bdaee5bd13780d295d7674231afd6?response-content-disposition=attachment%3Bfilename%3D%22jackson-databind-2.11.1.jar%22&Policy=eyJTdGF0ZW1lbnQiOiBbeyJSZXNvdXJjZSI6Imh0dHAqOi8vZDI5dnprNG93MDd3aTcuY2xvdWRmcm9udC5uZXQvYjQ4NmJlMzlkOWZmNGFlOGJjNzc4Mjc5MmYyZWE3MGYzYTdiZGFlZTViZDEzNzgwZDI5NWQ3Njc0MjMxYWZkNj9yZXNwb25zZS1jb250ZW50LWRpc3Bvc2l0aW9uPWF0dGFjaG1lbnQlM0JmaWxlbmFtZSUzRCUyMmphY2tzb24tZGF0YWJpbmQtMi4xMS4xLmphciUyMiIsIkNvbmRpdGlvbiI6eyJEYXRlTGVzc1RoYW4iOnsiQVdTOkVwb2NoVGltZSI6MTYwNTE3MTE0MX0sIklwQWRkcmVzcyI6eyJBV1M6U291cmNlSXAiOiIwLjAuMC4wLzAifX19XX0_&Signature=bM41FNo-OvNW78AqSzz0gkc8lm~hglLlsMvaiR1VAKATS1dutM7wmtCo71i9mSlZO~GzueBh-v4-5g7eXiMEQ2A-gukx4xO8T4VzooQbivf1ctfclEbCFgLXv9mLaxvvFyO2qq~i6tp3yxP7M8OUbdcloELYz9hl53dRnkUu6nc1qmaWVMXTXpzwJy9HBlOdKeb1yWoggXvsXM201LMoECv5tZpa2mvnuvIjL3lgNG3yIJcUWV8Z0xlXleX9gGydm53m9bkolJuSPh4tSxx91SBJe3xSIy0RrsTuA0zGr2h2dLF7RqoKaLti-MfMq16YTRYXtLX6UvKBEl1aQPNeGg__&Key-Pair-Id=APKAIFKFWOMXM2UMTSFA'.
            > Read timed out
   > Could not download jackson-core.jar (com.fasterxml.jackson.core:jackson-core:2.11.1)
      > Could not get resource 'https://plugins.gradle.org/m2/com/fasterxml/jackson/core/jackson-core/2.11.1/jackson-core-2.11.1.jar'.
         > Could not GET 'https://d29vzk4ow07wi7.cloudfront.net/25461dbfb431cb48e30118a0277671de8e8a56a3b1198492e24b2fb605d7575e?response-content-disposition=attachment%3Bfilename%3D%22jackson-core-2.11.1.jar%22&Policy=eyJTdGF0ZW1lbnQiOiBbeyJSZXNvdXJjZSI6Imh0dHAqOi8vZDI5dnprNG93MDd3aTcuY2xvdWRmcm9udC5uZXQvMjU0NjFkYmZiNDMxY2I0OGUzMDExOGEwMjc3NjcxZGU4ZThhNTZhM2IxMTk4NDkyZTI0YjJmYjYwNWQ3NTc1ZT9yZXNwb25zZS1jb250ZW50LWRpc3Bvc2l0aW9uPWF0dGFjaG1lbnQlM0JmaWxlbmFtZSUzRCUyMmphY2tzb24tY29yZS0yLjExLjEuamFyJTIyIiwiQ29uZGl0aW9uIjp7IkRhdGVMZXNzVGhhbiI6eyJBV1M6RXBvY2hUaW1lIjoxNjA1MTcwNzc3fSwiSXBBZGRyZXNzIjp7IkFXUzpTb3VyY2VJcCI6IjAuMC4wLjAvMCJ9fX1dfQ__&Signature=Qfn0elWmkzS4pkLWwdov8f~VvSKzI2gW89--pKdmUvVzJPeUOsGA7~-Vujj0p0R6OsI56Urx9GRiDV9kJ09gSB4Ts5sQHuQCA2594eKdMnU4jG8mUrQuYoISkychBP7MnZstwBO-SYdlzZK9-gy4HkbUfeZwRmXqbXucUVS7R4NAYbITY-MIuT9Bjtz-DKfIIqxRRN3HFEx63tcbNEAd2SNimXa80hHxSZEVd5c5ysah1PUyAsa--w17VwI28R9IT5PB9XmCVKz1fTEILxe5~p~D1q9ICWyh6q6ibgX-HtD0eus2SCJBMup5I03Ikp2gvTPGZNbi3JHbrCxdtqucSA__&Key-Pair-Id=APKAIFKFWOMXM2UMTSFA'.
            > Read timed out

Environments

The environments are as follows:

  • java version: jdk 1.8
  • spring boot version: 2.3.2.RELEASE

The build.gradle

The build.gradle of this spring boot application is as follows:

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

group 'com.bswen'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
}

How to solve the problem

I think this error is caused by the incorrectly set repositories block in the build.gradle file, let’s add them:

   mavenLocal()
   maven { url 'https://maven.aliyun.com/repository/google/' }
   maven { url 'https://maven.aliyun.com/repository/public/' }
   maven { url 'https://maven.aliyun.com/repository/spring/' }
   maven { url 'https://maven.aliyun.com/repository/gradle-plugin/' }
   maven { url 'https://maven.aliyun.com/repository/spring-plugin/' }

These repositories for build.gradle are provided by aliyun.com. You can add appropriate repositories to the build.gradle file in your project.

After this change, the whole build.gradle file is as follows:

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

group 'com.bswen'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
    mavenLocal()
    maven { url 'https://maven.aliyun.com/repository/google/' }
    maven { url 'https://maven.aliyun.com/repository/public/' }
    maven { url 'https://maven.aliyun.com/repository/spring/' }
    maven { url 'https://maven.aliyun.com/repository/gradle-plugin/' }
    maven { url 'https://maven.aliyun.com/repository/spring-plugin/' }

    mavenCentral()
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
}

The code base of this example is uploaded to github.com, you can click this web url to download the code.

References

You can view some references as follows: