spring mvc/mybatis整合,junit测试报BeanCreationException
2016-06-24 10:32
399 查看
<pre name="code" class="java"> org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.hft.dal.mapper.AccountMapperTest': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.hft.dal.mapper.AccountMapper com.hft.dal.mapper.AccountMapperTest.accountMapper; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.hft.dal.mapper.AccountMapper] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations:
检查后发现
@ContextConfiguration(locations = { "classpath: spring-mybatis.xml", "classpath:applicationContext.xml"})
在classpath那块中间多了一个空格,造成没有扫描到spring-mybatis.xml配置文件, 注意也如果使用classpath* 的时候如果没有找打配置文件是会忽略不会报错的,所以如果确定配置文件只有一个尽量使用classpath
相关文章推荐
- Android之使用Http协议实现文件上传功能
- 一个jar包里的网站
- 一个jar包里的网站之文件上传
- 一个jar包里的网站之返回对媒体类型
- Spring和ThreadLocal
- Spring Boot 开发微服务
- Spring AOP动态代理-切面
- mysql集群之MMM简单搭建
- Spring整合Quartz(JobDetailBean方式)
- Spring整合Quartz(JobDetailBean方式)
- 通晓网络测试常用命令
- Nodejs学习笔记之测试驱动
- 模拟Spring的简单实现
- Spring整合WebSocket应用示例(上)
- spring+html5实现安全传输随机数字密码键盘
- Spring中属性注入详解
- 监听器获取Spring配置文件的方法
- Java利用Sping框架编写RPC远程过程调用服务的教程
- springmvc 发送ajax出现中文乱码的解决方法汇总