我也是无法验证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的知识再来学习视频比较好,不然会遇到很多奇怪的问题,建议一定要在理解的基础上去搭建,这样才不容易出错



0
2
翔仔
回复
qq_小鱼干的熊大傻_rsyAQ2
同学加油,结合同学目前的情况一个星期感觉不是很够,并且平时是上班的,没办法做到及时答复,同学可以加到q群里和其他同学请教哈
2018-11-07
共2条回复

Java双版本(SSM到SpringBoot)校园商铺全栈开发

SSM商铺V1.0,解决毕设痛点;SpringBoot商铺V2.0,满足工作刚需

5113 学习 · 8144 问题

查看课程