【问题标题】:intellij Gradle Sync Error : "Could not resolve all artifacts for configuration ':classpath'."intellij Gradle 同步错误:“无法解析配置':classpath'的所有工件。”
【发布时间】:2021-10-25 07:44:30
【问题描述】:

这是我的 build.gradle

buildscript {
    ext {
        springBootVersion = '2.1.7.REALEASE'
    }
    repositories {
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

group 'org.example'
version '1.0-SNAPSHOT'

repositories {
    mavenCentral()
}

dependencies {
    compile('org.springframework.boot:spring-boot-starter-web:')
    testCompile('org.springframework.boot:spring-boot-starter-test:')
}

这是同步错误消息

无法解析配置“:classpath”的所有工件。 找不到 org.springframework.boot:spring-boot-gradle-plugin:2.1.7.REALEASE。 在以下位置搜索: - https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-gradle-plugin/2.1.7.REALEASE/spring-boot-gradle-plugin-2.1.7.REALEASE.pom - https://jcenter.bintray.com/org/springframework/boot/spring-boot-gradle-plugin/2.1.7.REALEASE/spring-boot-gradle-plugin-2.1.7.REALEASE.pom 要求: 项目:

可能的解决方案:

有明确声明的仓库,如 mavenCentral() 和 jcnenter(),但无法构建。

【问题讨论】:

  • 是否可以在 IDE 之外构建命令行?
  • 我在 cmd 中尝试过(使用命令“gradle build”),但仍然给我一条错误消息“FAILURE: Build failed with an exception。”
  • 你是否在一个 Gradle 项目中遇到同样的问题?

标签: spring-boot gradle intellij-idea


【解决方案1】:

我被告知不再为 jcenter 提供服务,所以我更改了依赖项并删除了 jcenter()。

此构建已成功运行。

buildscript {
    ext{
        springBootVersion = '2.1.7.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

group 'org.example'
version '1.0-SNAPSHOT'

repositories {
    mavenCentral()
}

dependencies {
    testImplementation 'org.junit.jupiter:junit-jupiter-api'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
}

test {
    useJUnitPlatform()
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-09-29
    • 1970-01-01
    • 2020-04-17
    • 2023-03-17
    • 2018-03-31
    • 2021-06-04
    • 2016-10-09
    • 2021-07-28
    相关资源
    最近更新 更多