0

I've been using gradle for Springboot and it used to be fine but all of the sudden the gradle build stopped working. I keep getting errors saying that dependencies can't be found.

Here is the gradle code:

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

version = '0.0.1'
sourceCompatibility = '1.8'

repositories {
    maven {
        url 'https://repo1.maven.org/'
    }
}

springBoot {
    buildInfo()
}

ext {
    set('springCloudServicesVersion', "2.4.1")
    set('springCloudVersion', "2020.0.3")
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-jdbc'
    implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'io.pivotal.spring.cloud:spring-cloud-services-starter-config-client'
    compileOnly 'org.projectlombok:lombok'
    runtimeOnly 'com.h2database:h2'
    runtimeOnly 'com.microsoft.sqlserver:mssql-jdbc'
    annotationProcessor 'org.projectlombok:lombok'
    testImplementation('org.springframework.boot:spring-boot-starter-test') {
        exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    }
    implementation 'org.springframework.boot:spring-boot-starter-integration'
    testImplementation('org.springframework.boot:spring-boot-starter-test')
    testImplementation 'org.springframework.integration:spring-integration-test'
    implementation 'org.springframework.integration:spring-integration-mail:5.5.1'
    implementation group: 'javax.mail', name: 'mail', version: '1.5.0-b01'
    implementation group: 'org.apache.velocity.tools', name: 'velocity-tools-generic', version: '3.0'
    implementation 'org.jsoup:jsoup:1.14.1'
    implementation 'com.microsoft.sqlserver:mssql-jdbc:7.4.1.jre8'

}

dependencyManagement {
    imports {
        mavenBom "io.pivotal.spring.cloud:spring-cloud-services-dependencies:${springCloudServicesVersion}"
        mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
    }
}

test {
    useJUnitPlatform()
}

The errors I'm getting:

Could not resolve org.springframework.boot:spring-boot-dependencies:2.4.1. Could not resolve io.pivotal.spring.cloud:spring-cloud-services-dependencies:2.4.1. Could not resolve org.springframework.cloud:spring-cloud-dependencies:2020.0.3.

Any Ideas?

1 Answers1

1

Your maven repository is wrong.

Change

repositories {
    maven {
        url 'https://repo1.maven.org/'
    }
}

to

repositories {
    mavenCentral()
}

See here a good explanation on how to declare the maven repository in your build.gradle file.

thepaoloboi
  • 708
  • 4
  • 13