【问题标题】:Gradle Build Can't find dependenciesGradle Build找不到依赖项
【发布时间】:2021-10-08 20:33:00
【问题描述】:

我一直在为 Springboot 使用 gradle,它曾经很好,但突然之间 gradle 构建停止工作。我不断收到错误消息,说找不到依赖项。

这是gradle代码:

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()
}

我遇到的错误:

无法解析 org.springframework.boot:spring-boot-dependencies:2.4.1。 无法解析 io.pivotal.spring.cloud:spring-cloud-services-dependencies:2.4.1。 无法解析 org.springframework.cloud:spring-cloud-dependencies:2020.0.3。

有什么想法吗?

【问题讨论】:

    标签: java spring spring-boot gradle


    【解决方案1】:

    您的 maven 存储库有误。

    改变

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

    repositories {
        mavenCentral()
    }
    

    请参阅here,了解如何在您的build.gradle 文件中声明 maven 存储库。

    【讨论】:

    • 你忘了放实际链接 ;-)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-04-23
    • 2021-07-10
    • 1970-01-01
    • 1970-01-01
    • 2021-02-02
    • 1970-01-01
    相关资源
    最近更新 更多