我也是无法验证DAO,主要是classpath:mapper/*.xml找不到,不清楚啥原因
来源:2-7 验证Dao
qq_小鱼干的熊大傻_rsyAQ2
2018-11-07
Caused by: 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 [classpath:mapper/.xml]: class path resource [mapper/] cannot be resolved to URL because it does not exist
at org.springframework.beans.AbstractNestablePropertyAccessor.convertIfNecessary(AbstractNestablePropertyAccessor.java:610)
at org.springframework.beans.AbstractNestablePropertyAccessor.convertForProperty(AbstractNestablePropertyAccessor.java:617)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:216)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1577)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1536)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1276)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
… 39 more
Caused by: java.lang.IllegalArgumentException: Could not resolve resource location pattern [classpath:mapper/.xml]: class path resource [mapper/] cannot be resolved to URL because it does not exist
1回答
-
翔仔
2018-11-07
错误非常明显 Caused by: 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 [classpath:mapper/.xml]: class path resource [mapper/] cannot be resolved to URL because it does not exist
同学你的spring-dao.xml配置应该有问题,或者你的mapper目录底下压根就没有mapper。请仔细检查
<property name="mapperLocations" value="classpath:mapper/*.xml" />
此外,感觉同学的基础还是需要加强一下,建议先学习一些spring还有mybatis的知识再来学习视频比较好,不然会遇到很多奇怪的问题,建议一定要在理解的基础上去搭建,这样才不容易出错
022018-11-07
相似问题