https://blog.csdn.net/gao505/article/details/81393472

 

Spring Cloud项目启动失败:class path resource [mapper/] cannot be resolved to URL because it does not exist

如下截图:

class path resource [mapper/] cannot be resolved to URL because it does not exist

这个是无法解析当前的URL,做出如下修改,classpath 后多加一个“ * ”,修复了这个错误。

修改后:

class path resource [mapper/] cannot be resolved to URL because it does not exist

classpath 和 classpath* 区别: 
classpath:只会到你的class路径中查找找文件; 
classpath*:不仅包含class路径,还包括jar文件中(class路径)进行查找。当项目中有多个classpath路径,并同时加载多个classpath路径下(此种情况多数不会遇到)的文件,*就发挥了作用,如果不加*,则表示仅仅加载第一个classpath路径;

如果要加载的资源, 不在当前ClassLoader的路径里,那么用classpath:前缀是找不到的, 这种情况下就需要使用classpath*:前缀 。

在多个classpath中存在同名资源,都需要加载, 那么用classpath:只会加载第一个,这种情况下也需要用classpath*:前缀 

注意: 
用classpath*:需要遍历所有的classpath,所以加载速度是很慢的,因此,在规划的时候,应该尽可能规划好资源文件所在的路径,尽量避免使用classpath*。

参考:http://perfy315.iteye.com/blog/2009258

经分析,这样会把依赖工程中的classpath下的都加载进来。最后还是使用classpath,IDEA在编译的时候,没把空文件夹mapper复制到target目录下,导致编译过程中找不到这个目录。所以在mapper目录下新建一个txt文件,避免空文件夹。重新运行就可以通过了。

相关文章:

  • 2021-09-04
  • 2021-10-20
  • 2021-06-27
  • 2021-10-19
  • 2020-01-07
  • 2021-11-04
  • 2022-12-23
猜你喜欢
  • 2021-07-03
  • 2021-08-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-29
  • 2021-11-25
相关资源
相似解决方案