从github上clone代码spring-framework到本地后导入idea,点击gradle构建后控制台提示异常:
具体异常信息:
/Users/ZengJun/Desktop/spring-framework/buildSrc/src/main/java/org/springframework/build/KotlinConventions.java:44: error: cannot find symbolfreeCompilerArgs.addAll(List.of("-Xsuppress-version-warnings", "-Xjsr305=strict", "-opt-in=kotlin.RequiresOptIn"));^symbol: method of(java.lang.String,java.lang.String,java.lang.String)location: interface java.util.List
环境信息:
spring-framework版本:6.1.2
mac版本:macOS Monterey Version 12.7.2 (21G1974)
idea版本:IntelliJ IDEA 2023.2.5 (Ultimate Edition)
gradle版本:8.4
jdk版本:1.8.0_202
问题原因:spring-framework与jdk版本不符
解决方案:
- jdk版本升级到17以上;
- spring-framework版本降到5.3.x及以下,gradle降到7.x以下;
附gradle与jdk版本对照表:https://docs.gradle.org/current/userguide/compatibility.html#compatibility