heroku Sping Boot Gradle构建失败

6uxekuva  于 2023-08-06  发布在  其他
关注(0)|答案(1)|浏览(122)

当我尝试构建项目时,我得到了这个错误(在部署到heroku时)。这是我的第一个Sping Boot 应用程序,老实说,我找不到任何解决这个问题的方法。我的Jdk是v.17

remote:        A problem occurred configuring root project 'demo'.
remote:        > Could not resolve all files for configuration ':classpath'.
remote:           > Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.0.1.
remote:             Required by:
remote:                 project : > org.springframework.boot:org.springframework.boot.gradle.plugin:3.0.1
remote:              > No matching variant of org.springframework.boot:spring-boot-gradle-plugin:3.0.1 was found. The consumer was configured to find a runtime of a library compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '7.6' but:
remote:                  - Variant 'apiElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.0.1 declares a library, packaged as a jar, and its dependencies declared externally:
remote:                      - Incompatible because this component declares an API of a component compatible with Java 17 and the consumer needed a runtime of a component compatible with Java 8
remote:                      - Other compatible attribute:
remote:                          - Doesn't say anything about org.gradle.plugin.api-version (required '7.6')
remote:                  - Variant 'javadocElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.0.1 declares a runtime of a component, and its dependencies declared externally:
remote:                      - Incompatible because this component declares documentation and the consumer needed a library
remote:                      - Other compatible attributes:
remote:                          - Doesn't say anything about its target Java version (required compatibility with Java 8)
remote:                          - Doesn't say anything about its elements (required them packaged as a jar)
remote:                          - Doesn't say anything about org.gradle.plugin.api-version (required '7.6')
remote:                  - Variant 'mavenOptionalApiElements' capability org.springframework.boot:spring-boot-gradle-plugin-maven-optional:3.0.1 declares a library, packaged as a jar, and its dependencies declared externally:
remote:                      - Incompatible because this component declares an API of a component compatible with Java 17 and the consumer needed a runtime of a component compatible with Java 8
remote:                      - Other compatible attribute:
remote:                          - Doesn't say anything about org.gradle.plugin.api-version (required '7.6')
remote:                  - Variant 'mavenOptionalRuntimeElements' capability org.springframework.boot:spring-boot-gradle-plugin-maven-optional:3.0.1 declares a runtime of a library, packaged as a jar, and its dependencies declared externally:
remote:                      - Incompatible because this component declares a component compatible with Java 17 and the consumer needed a component compatible with Java 8
remote:                      - Other compatible attribute:
remote:                          - Doesn't say anything about org.gradle.plugin.api-version (required '7.6')
remote:                  - Variant 'runtimeElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.0.1 declares a runtime of a library, packaged as a jar, and its dependencies declared externally:
remote:                      - Incompatible because this component declares a component compatible with Java 17 and the consumer needed a component compatible with Java 8
remote:                      - Other compatible attribute:
remote:                          - Doesn't say anything about org.gradle.plugin.api-version (required '7.6')
remote:                  - Variant 'sourcesElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.0.1 declares a runtime of a component, and its dependencies declared externally:
remote:                      - Incompatible because this component declares documentation and the consumer needed a library
remote:                      - Other compatible attributes:
remote:                          - Doesn't say anything about its target Java version (required compatibility with Java 8)
remote:                          - Doesn't say anything about its elements (required them packaged as a jar)
remote:                          - Doesn't say anything about org.gradle.plugin.api-version (required '7.6')

字符串
编辑:
下面是build.gradle文件配置。也许有些依赖是不兼容的?

plugins {
    id 'java-library'
    id 'org.springframework.boot' version '3.0.1'
    id 'io.spring.dependency-management' version '1.1.0'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-validation'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    compileOnly 'org.projectlombok:lombok'
    runtimeOnly 'org.postgresql:postgresql'
    annotationProcessor 'org.projectlombok:lombok'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    implementation group: 'com.opencsv', name: 'opencsv', version: '5.7.1'
    implementation group: 'org.modelmapper', name: 'modelmapper', version: '3.1.1'

}

tasks.named('test') {
    useJUnitPlatform()
}

6ioyuze2

6ioyuze21#

如果您使用的是InteliJ,则需要转到文件>设置>构建、执行、部署>构建工具> Gradle并将Gradle JVM更改为17。
干杯

相关问题