SpringBoot3启动报错 java.lang.ClassNotFoundException: java.text.ListFormat
问题
在使用SpringBoot3创建web项目的时候日志报错java.lang.ClassNotFoundException: java.text.ListFormat
.
具体报错如下:
java.lang.ClassNotFoundException: java.text.ListFormat
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[na:na]
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[na:na]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526) ~[na:na]
at java.base/java.lang.Class.forName0(Native Method) ~[na:na]
at java.base/java.lang.Class.forName(Class.java:421) ~[na:na]
at java.base/java.lang.Class.forName(Class.java:412) ~[na:na]
at org.apache.tomcat.util.compat.Jre22Compat.<clinit>(Jre22Compat.java:37) ~[tomcat-embed-core-10.1.24.jar:10.1.24]
at org.apache.tomcat.util.compat.JreCompat.<clinit>(JreCompat.java:55) ~[tomcat-embed-core-10.1.24.jar:10.1.24]
at org.apache.catalina.startup.Tomcat.<clinit>(Tomcat.java:1193) ~[tomcat-embed-core-10.1.24.jar:10.1.24]
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:203) ~[spring-boot-3.3.0.jar:3.3.0]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:188) ~[spring-boot-3.3.0.jar:3.3.0]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:162) ~[spring-boot-3.3.0.jar:3.3.0]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:618) ~[spring-context-6.1.8.jar:6.1.8]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.3.0.jar:3.3.0]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) ~[spring-boot-3.3.0.jar:3.3.0]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456) ~[spring-boot-3.3.0.jar:3.3.0]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:335) ~[spring-boot-3.3.0.jar:3.3.0]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1363) ~[spring-boot-3.3.0.jar:3.3.0]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1352) ~[spring-boot-3.3.0.jar:3.3.0]
at com.zjw.lease.AdminWebApplication.main(AdminWebApplication.java:17) ~[classes/:na]
可以看出是找不到java.text.ListFormat
类,这就很奇怪,这是jdk中的类为什么会找不到呢?
排查
我的环境:
- SpringBoot 3.3
- OpenJDK 21
发现java.text.ListFormat
是在jdk22
中才有的,我的使用的是jdk21
。
解决办法
可以把JDK换成JDK22
---------------
我每一次回头,都感觉自己不够努力,所以我不再回头。
---------------