由于我没有Gradle版本和源代码8,Gradle构建失败



我正在尝试构建和运行一个项目,但我收到了这些错误/警告。文档说它需要JVM 10和Gradle 6:

D:GITgeospring-boot>.gradlew  bootRun
> Task :compileJava FAILED
D:GITgeospring-bootsrcmainjavamodule-info.java:1: error: modules are not supported in -source 
8
module Geo {
^
(use -source 9 or higher to enable modules)
1 error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.
* 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
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.2.2/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 1s
1 actionable task: 1 executed

我看到这个消息:use -source 9 or higher to enable modules然而,它看起来像是在使用java10

D:GITgeospring-boot>java -version
openjdk version "10" 2018-03-20
OpenJDK Runtime Environment 18.3 (build 10+44)
OpenJDK 64-Bit Server VM 18.3 (build 10+44, mixed mode)

我还看到了以下消息:Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.但看起来我使用的是Gradle 2.2

D:GITgeospring-boot>.gradlew -v
------------------------------------------------------------
Gradle 6.2.2
------------------------------------------------------------
Build time:   2020-03-04 08:49:31 UTC
Revision:     7d0bf6dcb46c143bcc3b7a0fa40a8e5ca28e5856
Kotlin:       1.3.61
Groovy:       2.5.8
Ant:          Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM:          10 ("Oracle Corporation" 10+44)
OS:           Windows Server 2016 10.0 amd64

您需要在构建脚本中设置版本

compileJava {
options.release = 10
}

https://docs.gradle.org/6.8.1/userguide/building_java_projects.html#sec:java_cross_compilation

最新更新