Spring引导gradle构建失败



当我尝试构建项目时,我得到这个错误(同时部署到heroku)。这是我的第一个春季启动应用程序,老实说,我找不到任何解决这个问题的方法。我的Jdk是v17

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')

编辑:

这是构建。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()
}

如果你使用的是InteliJ,你需要点击File>设置在构建、执行、部署;构建工具>

欢呼

最新更新