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

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

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

 classpath 和 classpath* 区别: 

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

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

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

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

所以在mapper目录下新建一个文件,避免空文件夹。重新运行就可以通过了。

posted on 2023-01-28 16:37  悄悄的来,匆匆的走  阅读(1029)  评论(0编辑  收藏  举报

导航