spring-boot-gradle-plugin:3.0.0忽略Java Toolchain配置致构建失败
Spring Boot Gradle插件忽略Java Toolchain配置导致依赖解析失败
发现spring-boot-gradle-plugin似乎忽略了我在build.gradle文件中声明的Java Toolchain配置,构建时出现以下错误:
> Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.0.0. Required by: project : > org.springframework.boot:org.springframework.boot.gradle.plugin:3.0.0 > No matching variant of org.springframework.boot:spring-boot-gradle-plugin:3.0.0 was found. The consumer was configured to find a runtime of a library compatible with Java 11, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '7.6' but: - Variant 'apiElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.0.0 declares a library, packaged as a jar, and its dependencies declared externally: - 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 11 - Other compatible attribute: - Doesn't say anything about org.gradle.plugin.api-version (required '7.6') - Variant 'javadocElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.0.0 declares a runtime of a component, and its dependencies declared externally: - Incompatible because this component declares documentation and the consumer needed a library - Other compatible attributes: - Doesn't say anything about its target Java version (required compatibility with Java 11) - Doesn't say anything about its elements (required them packaged as a jar) - Doesn't say anything about org.gradle.plugin.api-version (required '7.6') - Variant 'mavenOptionalApiElements' capability org.springframework.boot:spring-boot-gradle-plugin-maven-optional:3.0.0 declares a library, packaged as a jar, and its dependencies declared externally: - 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 11 - Other compatible attribute: - Doesn't say anything about org.gradle.plugin.api-version (required '7.6') - Variant 'mavenOptionalRuntimeElements' capability org.springframework.boot:spring-boot-gradle-plugin-maven-optional:3.0.0 declares a runtime of a library, packaged as a jar, and its dependencies declared externally: - Incompatible because this component declares a component compatible with Java 17 and the consumer needed a component compatible with Java 11 - Other compatible attribute: - Doesn't say anything about org.gradle.plugin.api-version (required '7.6') - Variant 'runtimeElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.0.0 declares a runtime of a library, packaged as a jar, and its dependencies declared externally: - Incompatible because this component declares a component compatible with Java 17 and the consumer needed a component compatible with Java 11 - Other compatible attribute: - Doesn't say anything about org.gradle.plugin.api-version (required '7.6') - Variant 'sourcesElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.0.0 declares a runtime of a component, and its dependencies declared externally: - Incompatible because this component declares documentation and the consumer needed a library - Other compatible attributes: - Doesn't say anything about its target Java version (required compatibility with Java 11) - Doesn't say anything about its elements (required them packaged as a jar) - Doesn't say anything about org.gradle.plugin.api-version (required '7.6') * 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 3s
我的build.gradle配置如下:
plugins { id 'org.springframework.boot' version '3.0.0' id 'io.spring.dependency-management' version '1.1.0' id 'groovy' id 'java' id "com.google.cloud.tools.jib" version "3.3.1" } group = 'dev' version = '0.0.2-SNAPSHOT' def app = "application-v2" repositories { maven{ url "${System.getenv("ARTIFACT_REPO")}".toString() name 'artifacts' credentials{ username = System.getenv("GIT_DEV") password = System.getenv("GIT_TOKEN") } } } jib{ from{ image = 'gcr.io/distroless/java17:latest' } to{ auth{ username= System.getenv("KUBE_USER") password= System.getenv("KUBE_TOKEN") } image = "${System.getenv("IMG_REPO")}/dev/application-v2".toString() } container{ environment = ["SPRING_CLOUD_CONFIG_LABEL": System.getenv("BRANCH_NAME")] jvmFlags = ["-Ddd.service.name=esg-apps-imaging-v2" ,"-Ddd.trace.span.tags=env:${System.getenv("BRANCH_NAME")}".toString()] ports = ["8443"] } } dependencies { implementation group: 'org.apache.groovy', name: 'groovy-all', version: '4.0.7' implementation 'org.springframework.boot:spring-boot-starter-web' implementation group: 'org.springframework.boot', name: 'spring-boot-starter-actuator' implementation group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.70' implementation group: 'org.springframework.security', name: 'spring-security-crypto', version: '5.7.2' implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.13.4.1' implementation 'com.microsoft.azure:applicationinsights-runtime-attach:3.4.8' implementation 'org.apache.commons:commons-text:1.10.0' implementation group: 'org.springframework', name: 'spring-messaging', version: '5.3.20' implementation 'org.apache.groovy:groovy-yaml:4.0.7' implementation fileTree(dir: "libs", include: "*.jar") implementation group: 'javax.xml.bind', name: 'jaxb-api', version: '2.4.0-b180830.0359' implementation group: 'javax.jws', name: 'javax.jws-api', version: '1.1' implementation group: 'javax.xml.soap', name: 'javax.xml.soap-api', version: '1.4.0' implementation group: 'javax.activation', name: 'activation', version: '1.1.1' implementation 'org.springdoc:springdoc-openapi-ui:1.6.14' implementation 'org.springdoc:springdoc-openapi-groovy:1.6.14' implementation group: 'commons-io', name: 'commons-io', version: '2.11.0' implementation 'ch.qos.logback.contrib:logback-json-classic:0.1.5' implementation 'ch.qos.logback.contrib:logback-jackson:0.1.5' testImplementation platform(group: 'org.spockframework', name: 'spock-bom', version: '2.4-M1-groovy-4.0') testImplementation "org.spockframework:spock-core" testImplementation "org.spockframework:spock-junit4" testImplementation 'org.springframework.boot:spring-boot-starter-test' } java{ toolchain{ languageVersion.set(JavaLanguageVersion.of(17)) } } test { useJUnitPlatform() testLogging { events "passed", "skipped", "failed" showStackTraces = true exceptionFormat = TestExceptionFormat.FULL } }
若移除该插件,仅在build.gradle中手动定义版本标签,项目即可正常编译。恳请各位指导我可能存在的问题。
内容的提问来源于stack exchange,提问作者NoobWebDev
相关产品推荐
相关产品推荐

