Error creating bean with name 'sqlSessionFactory' defined in class path resource [applicationContext

Error creating bean with name 'sqlSessionFactory' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java.lang.String' to required type 'org.springframework.core.io.Resource[]' for property 'mapperLocations'; nested exception is java.lang.IllegalArgumentException: Could not resolve resource location pattern [com/lee/mapper/*.xml]: ServletContext resource [/com/lee/mapper/] cannot be resolved to URL because it does not exist

今天在做SSM项目的时候启动发现报如上所示的错误,错误大致的意思就是无法创建一个名为sqlSessionFactory的bean,而且出错地方是mapperLocations,出现该错误可能是两种原因造成的。

一:<property name="mapperLocations" value="com/lee/mapper/*.xml"></property>

在value中没有加classpath:

改正:<property name="mapperLocations" value="classpath:com/lee/mapper/*.xml"></property>

二:可能有多个mapper.xml文件的namespace重复了。

发布了63 篇原创文章 · 获赞 28 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/qq_41286145/article/details/103391478