如何修复构建gradle失败

问题描述 投票:0回答:1

这是错误代码

Build file 'C:\Users\SSAFY\Desktop\jae\pjt1\sub1\skeleton-project\backend_skeleton\build.gradle' line: 19

A problem occurred evaluating root project 'ssafy'.
> org.gradle.api.internal.artifacts.dsl.LazyPublishArtifact.<init>(Lorg/gradle/api/provider/Provider;)V

* 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.
BUILD FAILED in 6s

这是我的build.gradle文件代码

buildscript {
    ext {
//        springBootVersion = '2.4.9'
        springBootVersion = '2.3.2.RELEASE'
    }
    repositories {
        maven { url 'https://repo.spring.io/release' }
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

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


    group = 'com.ssafy'
    version '0.0.1'

    targetCompatibility = 1.8
    sourceCompatibility = 1.8
    compileJava.options.encoding = 'UTF-8'

    configurations {
        developmentOnly
        runtimeClasspath {
            extendsFrom developmentOnly
        }
        compileOnly {
            extendsFrom annotationProcessor
        }
    }


    repositories {
        mavenCentral()

        flatDir {
            dirs 'libs'
        }
    }
}

project(":core-module") {
    apply plugin: 'org.springframework.boot'
    apply plugin: 'io.spring.dependency-management'

    bootJar.enabled = false
    jar.enabled = true

    dependencies {
        implementation 'org.springframework.boot:spring-boot-starter-web'
        implementation('org.springframework.boot:spring-boot-starter-data-jpa')
        implementation 'org.springframework.boot:spring-boot-starter-security'
        implementation('org.projectlombok:lombok')
        implementation 'io.jsonwebtoken:jjwt:0.9.1'
        developmentOnly 'org.springframework.boot:spring-boot-devtools'
        implementation 'org.springframework.boot:spring-boot-starter-mail'
        implementation('org.springframework.boot:spring-boot-starter-logging')
        implementation "org.springframework.boot:spring-boot-configuration-processor"
        implementation 'org.springframework.boot:spring-boot-starter-freemarker'
        implementation 'org.springframework.boot:spring-boot-starter-actuator'
        implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5'
        implementation group: 'org.apache.httpcomponents', name: 'httpmime', version: '4.3.1'
        // S3
        implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-aws', version: '2.2.1.RELEASE'

        runtime('com.h2database:h2')
        runtimeOnly 'org.mariadb.jdbc:mariadb-java-client'
        testImplementation("org.springframework.boot:spring-boot-starter-test")

        compile fileTree(dir: 'libs', include: ['*.jar'])

        //querydsl 추가
        implementation 'com.querydsl:querydsl-jpa'
        //querydsl 추가
        implementation 'com.querydsl:querydsl-apt'
    }
}

project(":api-module") {
    apply plugin: 'org.springframework.boot'
    apply plugin: 'io.spring.dependency-management'
    apply plugin: 'java-library'


    bootJar{
        archivesBaseName = 'ssafy'
        archiveFileName = 'ssafy-api-module-0.0.1.jar'
        archiveVersion = "0.0.1"
    }

    dependencies {
        compile project(":core-module")
        implementation('org.springframework.boot:spring-boot-starter-data-jpa')
        implementation 'org.springframework.boot:spring-boot-starter-web'
        implementation 'org.springframework.boot:spring-boot-starter-validation'
        implementation 'org.springframework.boot:spring-boot-starter-security'
        implementation 'io.jsonwebtoken:jjwt:0.9.1'
        implementation 'com.google.code.gson:gson:2.8.5'
        compileOnly 'org.projectlombok:lombok'
        annotationProcessor 'org.projectlombok:lombok'
        testImplementation 'org.springframework.boot:spring-boot-starter-test'

        implementation 'net.rakugakibox.util:yaml-resource-bundle:1.1'
        implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-aws', version: '2.2.1.RELEASE'

        implementation 'com.google.firebase:firebase-admin:6.8.1'
        implementation 'com.google.gms:google-services:3.0.0'

        implementation group: 'com.github.scribejava', name: 'scribejava-core', version: '8.3.1'
        implementation group: 'com.github.scribejava', name: 'scribejava-apis', version: '8.3.1'
        compile group: 'io.springfox', name: 'springfox-swagger2', version: '2.9.2'
        compile group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.9.2'

        //JUnit4 추가
        testImplementation("org.junit.vintage:junit-vintage-engine") {
            exclude group: "org.hamcrest", module: "hamcrest-core"
        }

        compile('org.springframework.boot:spring-boot-starter-cache')
        compile group: 'org.apache.poi', name: 'poi', version: '3.11'
        compile group: 'org.apache.poi', name: 'poi-ooxml', version: '3.11'
        compile group: 'commons-io', name: 'commons-io', version: '2.4'
        compile fileTree(dir: 'libs', include: ['*.jar'])

    }
}

project(":batch-module") {
    apply plugin: 'org.springframework.boot'
    apply plugin: 'io.spring.dependency-management'
    apply plugin: 'java-library'


    bootJar{
        archivesBaseName = 'ssafy'
        archiveFileName = 'ssafy-batch-module-0.0.1.jar'
        archiveVersion = "0.0.1"
    }

    dependencies {
        compile project(":core-module")
        implementation('org.springframework.boot:spring-boot-starter-data-jpa')
        implementation 'org.springframework.boot:spring-boot-starter-web'
        implementation 'org.springframework.boot:spring-boot-starter-security'
        implementation 'com.google.code.gson:gson:2.8.5'
        compileOnly 'org.projectlombok:lombok'
        annotationProcessor 'org.projectlombok:lombok'
        testImplementation 'org.springframework.boot:spring-boot-starter-test'

        implementation 'net.rakugakibox.util:yaml-resource-bundle:1.1'

        implementation 'com.google.firebase:firebase-admin:6.8.1'
        implementation 'com.google.gms:google-services:3.0.0'

        implementation group: 'com.github.scribejava', name: 'scribejava-core', version: '8.3.1'
        implementation group: 'com.github.scribejava', name: 'scribejava-apis', version: '8.3.1'

        //JUnit4 추가
        testImplementation("org.junit.vintage:junit-vintage-engine") {
            exclude group: "org.hamcrest", module: "hamcrest-core"
        }

        compile('org.springframework.boot:spring-boot-starter-cache')
        compile group: 'commons-io', name: 'commons-io', version: '2.4'
        compile fileTree(dir: 'libs', include: ['*.jar'])

    }
}

project(":cms-module") {
    apply plugin: 'org.springframework.boot'
    apply plugin: 'io.spring.dependency-management'
    apply plugin: 'java-library'


    bootJar{
        archivesBaseName = 'ssafy'
        archiveFileName = 'ssafy-cms-module-0.0.1.jar'
        archiveVersion = "0.0.1"
    }

    configurations {
        all {
            exclude group : 'org.springframework.boot', module: 'spring-boot-starter-logging'
        }
    }

    dependencies {
        compile project(":core-module")
        implementation('org.springframework.boot:spring-boot-starter-data-jpa')
        implementation 'org.springframework.boot:spring-boot-starter'
        implementation 'org.springframework.boot:spring-boot-starter-web'
        implementation 'org.springframework.boot:spring-boot-starter-validation'
        implementation 'org.springframework.boot:spring-boot-starter-security'
        implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
        implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity5'
        implementation 'io.jsonwebtoken:jjwt:0.9.1'
        implementation('nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect')
        implementation 'com.google.code.gson:gson:2.8.5'
        implementation group: 'org.thymeleaf.extras', name: 'thymeleaf-extras-java8time', version: '3.0.1.RELEASE'
        implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.3'
        implementation 'org.springframework.boot:spring-boot-starter-log4j2'
        implementation 'org.bgee.log4jdbc-log4j2:log4jdbc-log4j2-jdbc4.1:1.16'
        implementation 'junit:junit:4.13.1'
        compileOnly 'org.projectlombok:lombok'
        annotationProcessor 'org.projectlombok:lombok'

        runtimeOnly 'org.mariadb.jdbc:mariadb-java-client'
        testImplementation 'org.springframework.boot:spring-boot-starter-test'
        testImplementation 'org.springframework.kafka:spring-kafka-test'
        testImplementation 'org.springframework.security:spring-security-test'

        implementation 'org.springframework.boot:spring-boot-devtools'

        implementation 'com.google.code.findbugs:jsr305:3.0.2'

        annotationProcessor('org.springframework.boot:spring-boot-configuration-processor')

    }
}

这是我的项目文件 enter image description here

这是19号线 应用插件:'org.springframework.boot'

我克隆了我的作业 git。

当我通过 intellij 打开这个项目时 然后开始构建 并发生错误

我把我的java版本降级到1.8

我该如何解决这个问题? 请帮助我

java spring-boot gradle build
1个回答
0
投票

您看到的错误消息表明您的项目中的 Gradle 构建脚本存在问题。当 Gradle 尝试评估您的根项目时会出现此问题,这表明 Gradle 功能可能存在不兼容或误用。

具体错误似乎与Gradle内部使用工件有关,这可能是由于过时的Gradle版本与您正在使用的Spring Boot Gradle插件版本不兼容引起的,或者可能存在与配置相关的其他问题您的项目。

您可以采取一些步骤来排除故障并希望解决问题:

  1. 检查 Gradle 版本:确保您使用的 Gradle 版本与

    build.gradle
    文件中指定的 Spring Boot Gradle 插件版本兼容。对于 Spring Boot
    2.3.2.RELEASE
    ,Gradle 6.x 应该兼容。

  2. 更新 Gradle 包装器

    • 如果您使用 Gradle 包装器(推荐),您可以通过在终端中运行以下命令来更新它:
      ./gradlew wrapper --gradle-version=6.8.3 --distribution-type=all
      
    • 如果更新成功,请确保将更改提交到
      gradle-wrapper.properties
      文件。
  3. 使用 Stacktrace 运行:要获取更详细的错误消息,请使用

    --stacktrace
    选项运行 Gradle 构建:

    ./gradlew build --stacktrace
    

    查看堆栈跟踪以确定构建失败的具体位置以及有关可能出现问题的任何线索。

  4. 检查插件应用程序

    org.springframework.boot
    插件可能被应用在错误的上下文中或被多次应用。通常,此插件应用在单个模块的
    build.gradle
    文件中,而不是根
    build.gradle
    文件中。确保这个插件没有被错误地应用到根目录
    build.gradle

  5. 检查 Gradle 插件:确保所有插件的版本彼此兼容。有时,插件不兼容可能会导致此类问题。

  6. 清洁和组装:尝试清洁您的项目并再次组装它:

    ./gradlew clean assemble
    
  7. 检查 IntelliJ 配置:确保 IntelliJ IDEA 已正确配置:

    • 使用 Gradle 工具窗口中的
      Refresh Gradle Project
      选项。
    • 检查 IntelliJ 是否设置为使用 Gradle 包装器,而不是可能过时的本地发行版。您可以在
      Settings
      Preferences
      >
      Build, Execution, Deployment
      >
      Build Tools
      >
      Gradle
      中查看。
  8. 检查项目JDK:确保IntelliJ IDEA中的JDK版本与您的项目所需的JDK版本匹配。

  9. 检查 Gradle 配置:仔细检查您的

    build.gradle
    配置,以确保没有语法错误、缺少括号或其他拼写错误。

© www.soinside.com 2019 - 2024. All rights reserved.