SpringBoot项目修改JDK后报错(class file version 55.0)

项目中更换JDK,由jdk9换到jdk11

报错信息

java.lang.UnsupportedClassVersionError: org/zjh/openlayersdemo/OpenlayersdemoApplication has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:495)
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" 

【原因】jdk不匹配

注:如果配置都已修改依旧报错,发现启动时还是以前的JDK,如下入,可以直接跳到最后
SpringBoot项目修改JDK后报错(class file version 55.0)_第1张图片

【解决方式】

1.pom修改11

    
        11
    

2.修改配置
ctrl + alt + shfit + s打开设置
选择SDKs
添加新的JDK
SpringBoot项目修改JDK后报错(class file version 55.0)_第2张图片
选择Modules
SpringBoot项目修改JDK后报错(class file version 55.0)_第3张图片
选择Project
SpringBoot项目修改JDK后报错(class file version 55.0)_第4张图片
最后,启动时配置
SpringBoot项目修改JDK后报错(class file version 55.0)_第5张图片
SpringBoot项目修改JDK后报错(class file version 55.0)_第6张图片

你可能感兴趣的:(Spring,boot,项目,spring,jdk)