0

The build.gradle.kts file looks like this:

buildscript {
    val springBootVersion by extra("2.1.3.RELEASE")

    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:$springBootVersion")
    }
}

plugins {
    java
    id("org.springframework.boot") version "2.1.3.RELEASE"
}

apply(plugin = "io.spring.dependency-management")

The error message is this:

* What went wrong:
Execution failed for task ':compileJava'.
> Could not resolve all dependencies for configuration ':detachedConfiguration1'.
> Cannot resolve external dependency org.springframework.boot:spring-boot-dependencies:2.1.3.RELEASE because no repositories are defined.
 Required by:
     project :

The gradle version is:

$ ./gradlew --version

------------------------------------------------------------
Gradle 5.2.1
------------------------------------------------------------

Build time:   2019-02-08 19:00:10 UTC
Revision:     f02764e074c32ee8851a4e1877dd1fea8ffb7183

Kotlin DSL:   1.1.3
Kotlin:       1.3.20
Groovy:       2.5.4
Ant:          Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM:          1.8.0_131 (Oracle Corporation 25.131-b11)
OS:           Linux 4.18.7-100.fc27.x86_64 amd64

The groovy dsl seems to work fine. Any help will be appreciated.

marcovmx07
  • 23
  • 6

2 Answers2

1

Remove the buildscript section, which is useless, and specify the repositories inside the build:

plugins {
    java
    id("org.springframework.boot") version "2.1.3.RELEASE"
}

apply(plugin = "io.spring.dependency-management")

repositories {
    mavenCentral()
}
JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255
  • Thanks, that works fine! Why would they insist in using the _bulidScript_ section in the documentation? – marcovmx07 Mar 07 '19 at 20:00
  • Where do "they" do that? I don't see any buildscript here: https://docs.spring.io/spring-boot/docs/current/gradle-plugin/reference/html/#getting-started – JB Nizet Mar 07 '19 at 20:04
0

I had to add mavenCentral in the allProjects section:

allprojects {
    repositories {
        mavenCentral()
    }
}

This post about buildscript vs allprojects can help clarify.

marcovmx07
  • 23
  • 6