第一次使用spring boot starter项目遇到的问题,记录下
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/springframework/boot/SpringApplication has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 59.0
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:151)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:825)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:723)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:646)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:604)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:168)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
at com.zjjj.Psi1Application.main(Psi1Application.java:10)
造成原因是创建项目时选择的spring boot 的运行环境选择高了。而eclipse的编译环境低了。
上图为查看eclipse最高编译环境。
创建spring boot 时我选择的运行环境。spring boot version 3.0.4(我理解为运行环境)
JDK version和class file version(Class编译版本号)对应关系jdk版本和Class编译版本对应关系_jdk52对应哪个版本_码灵的博客-CSDN博客
来源地址:https://blog.csdn.net/zhaomissnan/article/details/129659974