java 找不到与org.springframework. Boot :spring-boot-gradle-plugin:3.0.5匹配的变体

pieyvz9o  于 2023-05-21  发布在  Java
关注(0)|答案(1)|浏览(297)

我在build.gradle中更新了springboot版本2.7.9到3.0.5,但无法构建项目,它说

> No matching variant of org.springframework.boot:spring-boot-gradle-plugin:3.0.5 was found. The consumer was configured to find a runtime of a library compatible with Java 14, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '7.4.2' but:
      - Variant 'apiElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.0.5 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 14.

我也试过把Java版本从17改为14,但还是一样。

flvlnr44

flvlnr441#

您需要确保使用java 17或更高版本运行gradle。
如果通过命令行运行build,请选中java -version
如果通过IDE(例如IDEA)运行构建,请确保IDE使用正确的Java。例如,对于IDEA,它可以在Settings -> Build,execution,deployment -> Gradle -> Gradle JVM中完成

相关问题