SpringBoot项目报错“java.base/jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to java.bas“

Posted 二木成林

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SpringBoot项目报错“java.base/jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to java.bas“相关的知识,希望对你有一定的参考价值。

异常

Exception in thread "main" java.lang.ClassCastException: java.base/jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to java.base/java.net.URLClassLoader
	at org.springframework.boot.devtools.restart.DefaultRestartInitializer.getUrls(DefaultRestartInitializer.java:93)
	at org.springframework.boot.devtools.restart.DefaultRestartInitializer.getInitialUrls(DefaultRestartInitializer.java:56)
	at org.springframework.boot.devtools.restart.Restarter.<init>(Restarter.java:140)
	at org.springframework.boot.devtools.restart.Restarter.initialize(Restarter.java:546)
	at org.springframework.boot.devtools.restart.RestartApplicationListener.onApplicationStartingEvent(RestartApplicationListener.java:67)
	at org.springframework.boot.devtools.restart.RestartApplicationListener.onApplicationEvent(RestartApplicationListener.java:45)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:122)
	at org.springframework.boot.context.event.EventPublishingRunListener.starting(EventPublishingRunListener.java:69)
	at org.springframework.boot.SpringApplicationRunListeners.starting(SpringApplicationRunListeners.java:48)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:292)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
	at com.atguigu.springcloud.DeptProvider8001_App.main(DeptProvider8001_App.java:13)

原因

在pom.xml中添加了如下的热部署依赖:

解决

删除掉这个热部署依赖,然后刷新maven的依赖包

 

以上是关于SpringBoot项目报错“java.base/jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to java.bas“的主要内容,如果未能解决你的问题,请参考以下文章

SpringBoot项目上传文件报错

springboot项目连接数据报错

翻车现场:解决SpringBoot项目启动访问后台JSP页面显示404报错

翻车现场:解决SpringBoot项目启动访问后台JSP页面显示404报错

翻车现场:解决SpringBoot项目启动访问后台JSP页面显示404报错

springboot创建项目后运行报错