【问题标题】:Error on build Spring gradle project generated from Spring Initializr从 Spring Initializr 生成的构建 Spring gradle 项目时出错
【发布时间】:2020-02-14 18:02:56
【问题描述】:

我使用一些依赖项从Spring 创建了一个名为test-jdbc-demo 的演示Gradle 项目,并且没有进行任何更改,只是使用Open -> build.gradle 文件在Intellij 上解压缩并导入,并尝试使用默认Intellij 中的Import窗户。导入时,项目未构建,并且出现有关 gradle 依赖项的错误。我在 Ubuntu 上使用 Intellij 2019.3、JDK 1.8。

错误

FAILURE: Build failed with an exception.

* Where:
Build file '/home/augusto.cadini/projects/Spring Applications/test-jdbc-demo/build.gradle' line: 2

* What went wrong:
Plugin [id: 'org.springframework.boot', version: '2.2.4.RELEASE'] was not found in any of the following sources:

- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'org.springframework.boot:org.springframework.boot.gradle.plugin:2.2.4.RELEASE')
  Searched in the following repositories:
    Gradle Central Plugin Repository

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

CONFIGURE FAILED in 208ms

build.gradle

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

group = 'com.jdbc'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'

repositories {
    mavenCentral()
}

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-web'
    testImplementation('org.springframework.boot:spring-boot-starter-test') {
        exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    }
}

test {
    useJUnitPlatform()
}

【问题讨论】:

  • 它是从命令行构建的吗? ./gradlew clean build

标签: java spring gradle intellij-idea


【解决方案1】:

这让我发疯了。我遇到了同样的错误(这是来自 Spring Initializr 生成的一个干净的项目)。原来这是 Gradle 版本的问题。当我从命令行运行构建时,我收到以下错误消息

一旦我更新了 gradle,它就可以毫无问题地构建。

【讨论】:

    猜你喜欢
    • 2018-04-01
    • 1970-01-01
    • 2019-04-19
    • 2013-04-09
    • 2021-11-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-20
    • 2020-08-18
    相关资源
    最近更新 更多