Class not found so assuming code is running on a pre-Java 9 JVM

问题描述:

idea进行springboot开发时,进行日志输出模式修改,之前没有对日志的级别进行设置,启动的时候也没有发现有什么问题。当把日志级别调整到debug时,启动springboot项目问题出现了,我当时用的jdk是1.8

Class not found so assuming code is running on a pre-Java 9 JVM

翻译:

找不到类,所以假设代码运行在java 9之前的jvm上

完整的异常信息:

2020-06-21 17:44:19.102 DEBUG 5524 --- [  restartedMain] o.apache.tomcat.util.compat.Jre9Compat   : Class not found so assuming code is running on a pre-Java 9 JVM

java.lang.ClassNotFoundException: java.lang.reflect.InaccessibleObjectException
	at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[na:1.8.0_241]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:418) ~[na:1.8.0_241]
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355) ~[na:1.8.0_241]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[na:1.8.0_241]
	at java.lang.Class.forName0(Native Method) ~[na:1.8.0_241]
	at java.lang.Class.forName(Class.java:264) ~[na:1.8.0_241]
	at org.apache.tomcat.util.compat.Jre9Compat.(Jre9Compat.java:81) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
	at org.apache.tomcat.util.compat.JreCompat.(JreCompat.java:55) [tomcat-embed-core-9.0.36.jar:9.0.36]
	at org.apache.catalina.startup.Tomcat.(Tomcat.java:1276) [tomcat-embed-core-9.0.36.jar:9.0.36]
	at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:177) [spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:178) [spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:158) [spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:545) [spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) [spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) [spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) [spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) [spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
	at com.lej.gmall.user.GmallUserApplication.main(GmallUserApplication.java:12) [classes/:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_241]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_241]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_241]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_241]
	at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.3.1.RELEASE.jar:2.3.1.RELEASE]

解决方法:

jdk更换更高的版本,我当时为了验证自己的猜测,在官网上下载了jdk11,然后重新设置项目的jdk,问题没有再出现,但是又出现了一个其他问题:org.apache.tomcat.jni.LibraryNotFoundError: Can't load library: C:\Users\IdeaProjects\springbootstudy\bin\tcnative-1.dll, Can't load library:  这个问题就是springboot自带的tomcat中应该没有tcnative-1.dll,于是才出现了这个问题,解决方法:从tomcat(tcnative-1.dll这个是分32位或者64位的,根据系统进行下载相关文件) bin目录中找该文件然后放到自己系统Windows\system32\目录下,然后重新启动程序,问题没再出现。

 

你可能感兴趣的:(#,spring,boot,#,idea)