classpath:只会到你的class路径中查找找文件;
classpath*:不仅包含class路径,还包括jar文件中(class路径)进行查找。当项目中有多个classpath路径,并同时加载多个classpath路径下(此种情况多数不会遇到)的文件,就发挥了作用,如果不加,则表示仅仅加载第一个classpath路径;
如果要加载的资源, 不在当前ClassLoader的路径里,那么用classpath:前缀是找不到的, 这种情况下就需要使用classpath*:前缀 。
在多个classpath中存在同名资源,都需要加载, 那么用classpath:只会加载第一个,这种情况下也需要用classpath*:前缀
注意:
用classpath*:需要遍历所有的classpath,所以加载速度是很慢的,因此,在规划的时候,应该尽可能规划好资源文件所在的路径,尽量避免使用classpath*。
所以当出现class path resource [spring/] cannot be resolved to URL because it does not exist的提示错误时,请考虑是不是这个问题吧!l