springMVC mybatis dao接口(mapper接口)注入失败
来源:互联网 发布:网络主播招聘是真的吗 编辑:程序博客网 时间:2024/06/05 08:48
报的错误是:
No qualifying bean oftype [com.*.*.*.*.*.dao.UserDao] foundfor
dependency: expected at least1 bean which qualifies as autowire
candidateforthis dependency. Dependency annotations:
{@javax.annotation.Resource(shareable=true, mappedName=, description=, name=, type=classjava.lang.Object,authenticationType=CONTAINER)}
错误描述:dao层的UserDao接口的对象不能注入
我的service是这样的
@Service("xxxService")
public class Hl7sysServiceImlp implements Hl7sysService {
@Resource
private Hl7SystemDao hl7sysdao;
@Override
public List<Hl7sys> searchHl7sys() throws Exception{
return hl7sysdao.selectAllSys();
}
}
可能的原因:
1、没有在上一层调用中加注解,如@Resource,可是我加了
2、配置文件不正确(路径要写对),但是我的是正确的
<!-- myBatis文件 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation" value="classpath:spring/mybatis-config.xml"/>
<!-- 因为映射接口文件不放在同一个包下,所以需要配置xml的位置 -->
<property name="mapperLocations" value="classpath:mapping/*.xml" />
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<!-- 配置接口包的位置 -->
<property name="basePackage" value="com.spring.dao"/>
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
</bean>
3、没有写实现接口的xml文件,我写了
4、根本就木有加载spring-mybatis.xml文件!这个原因比较隐蔽!需要
在web.xml中添加上下文监听器
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/spring-mybatis.xml</param-value>
</context-param>
<!-- 上下文监听器 -->
至此,问题解决!!感谢这篇博客
http://blog.csdn.net/u012385190/article/details/53186552
- springMVC mybatis dao接口(mapper接口)注入失败
- springMVC mybatis整合dao接口(mapper接口) spring注入失败
- spring mybatis 整合后mapper接口注入失败问题
- Mybatis-Dao层开发之Mapper接口
- spring mybatis mapper接口注解方式注入
- myBatis Mapper接口注入null指针
- spring mybatis mapper接口注解方式注入
- spring mybatis mapper接口注解方式注入
- Mybatis接口注入失败问题
- mybatis自动生成mapper+pojo(mapper接口和普通dao)
- SpringMVC+MyBatis自动生成Dao接口
- mybatis-generator自动创建model,mapper和dao接口
- Mybatis之使用mapper代理方法开发dao(程序员只需要写mapper接口(dao接口))(12)
- mybatis+SpringMVC中mybatis实例化接口Dao原理
- MyBatis(5)MyBatis DAO接口开发
- SpringMvc+Mybatis 创建mapper接口引发的异常
- SpringMVC + Mybatis模式 MapperScannerConfigurer 自动扫描Mapper接口
- spring+springmvc+mybatis(2)--mapper代替dao开发
- 实现二叉树的先序遍历、中序遍历、后序遍历
- python-文件
- LSTM该不该使用RELU?
- 12月20号的作业
- 这些问题将导致信用卡降额,让你损失几十万
- springMVC mybatis dao接口(mapper接口)注入失败
- ubuntu 查看显卡
- Log4j日志配置
- 让p 和 span标签自动换行的css语句
- Fragment 购物车适配器
- 临颍县现代农业示范园区物联网水肥一体化项目
- Intellij IDEA——常用快捷键介绍 +快捷键大全汇总
- WebGIS 中电子地图Scale和Resolution参数及其互转
- 世峰数字——柯木塱展馆“增强现实、虚拟现实互动”方案