class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoade

在码云上下载的另一个springboot项目,启动报错:class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap')

解决方案:

  • 将pom.xml中的热部署依赖去掉(或注释掉)

<dependency>
   <groupId>org.springframework.bootgroupId>
   <artifactId>spring-boot-devtoolsartifactId>
   <optional>trueoptional>
   <scope>truescope>
dependency>
  • 将SpringBoot版本升到2.x版本:
    修改前:
<parent>
        <groupId>org.springframework.bootgroupId>
        <artifactId>spring-boot-starter-parentartifactId>
        <version>1.5.9.RELEASEversion>
        <relativePath/> 
    parent>

修改后:

 <parent>
        <groupId>org.springframework.bootgroupId>
        <artifactId>spring-boot-starter-parentartifactId>
        <version>2.1.3.RELEASEversion>
        <relativePath/>
    parent>

总结:将项目中的热部署依赖注释,并将springboot由原来的1.5.9升级到2.1.3后,该问题解决。

原文链接:

  • https://blog.csdn.net/qq_40722208/article/details/105287695

你可能感兴趣的:(spring,boot,maven,pom.xml)