错误原因:没有引入相应mapper接口,导致spring没有找到依赖

解决方法一:使用注解的方法:

首先在spring配置文件中添加

<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="com.forum" />
        <property name="annotationClass" value="org.springframework.stereotype.Repository" />
        <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
    </bean>

然后在mapper接口中添加注解

@Transactional
@Repository
public interface RoleMapper

解决方法二:使用xml配置定义mapper的bean

<!— mapper bean -->  
<bean id="roleMapper" class="org.mybatis.spring.MapperFactoryBean">  
    <property name="mapperInterface" value="com.forum.dao.RoleMapper" />  
    <property name="sqlSessionFactory" ref="sqlSessionFactory" />  
</bean>

不过第二种方法有点繁琐,假如有多个mapper接口的时候,可能要配置多个bean,那就太多了,能把文件撑爆。

mybatis expected at least 1 bean which qualifies as autowire candidate for this dependency的更多相关文章

  1. NoSuchBeanDefinitionException:No qualifying bean of type found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency.

    报错如下: NoSuchBeanDefinitionException:No qualifying bean of type   found for dependency: expected at l ...

  2. No matching bean of type [xx] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency

    这个看起来很弱爆的问题其实是因为其他的配置文件中已经出现了为xx定义好的注入.如果用@Autowired就会得到上面的错误 , 但是用@Resource的时候就会看到类似下面的错误 Bean name ...

  3. Caused by:org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type "" available: expected at least 1 bean which qualifies as autowire candidate

    项目使用spring, mybatis.因为分了多个模块,所以会这个模块引用了其它模块的现在,结果使用Junit测试的时候发现有两个模块不能自动注入dao和service问题.解决后在此记录一下. 解 ...

  4. spring加载bean报错:expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}

    看具体报错日志: 警告: Unable to proxy interface-implementing method [public final void cn.wlf.selection.proto ...

  5. springboot available: expected at least 1 bean which qualifies as autowire candidate奇葩问题

    Exception encountered during context initialization - cancelling refresh attempt: org.springframewor ...

  6. NoSuchBeanDefinitionException: No qualifying bean of type 'com.bj186.ssm.mapper.EmployeeMapper' available: expected at least 1 bean which qualifies as autowire candidate

    在搭建SSM spring springmvc  mybatis整合的时候, 遇到了这个问题 说说我的问题吧!我在进行单元测试的时候,出现了这个错误,网上一查才知道是,配置文件中没有写扫描包信息.一看 ...

  7. 【java异常】expected at least 1 bean which qualifies as autowire candidate for this depende

    1.查看接口实现类是否加入注解,如service.repository等 2.查看spring配置文件是否自动扫描包    <context:component-scan base-packag ...

  8. org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.oskyhang.gbd.service.UserService] found for dependency: expected at least 1 bean which qualifies as aut

    spring中一个符号的错误居然让我浪费了四五个小时才找出来,不得不给自己了两个耳光.. 由于新建项目与原来项目的目录结构有所不同,copy过来的配置文件,有些地方修改的不彻底,导致spring扫描注 ...

  9. Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.thinkplatform.dao.UserLogDao' available: expected at least 1 bean which qualifies as autowi

    我出错的问题是: 检查:

随机推荐

  1. SQL Server 更新 触发器

    - 复制代码 代码如下: create trigger TR_MasterTable_Update on MasterTable after update as if update ([Type])- ...

  2. iOS:第三方框架MJPhotoBrowser图片浏览器的使用

    介绍:MJPhotoBrowser这个第三方库是MJ老师封装的一套用来浏览图片的浏览器,可是是本地图片.网络图片.gif图片等,其也依赖了SDWebImage.SVProgressHUD.YLGIFI ...

  3. iOS: performXXX的几种方法总结:

    performXXX的用法: 视图切换: ※根据segue标识符切换视图 performSegueWithIdentifier:(NSString *) identifier sender:(id) ...

  4. screen space reflection/soft alpha test/

    http://www.crytek.com/cryengine/presentations/secrets-of-cryengine-3-graphics-technology 很多宝贝里面 不止题目 ...

  5. nginx搭建前端项目web服务器以及利用反向代理调试远程后台接口

    前端同学用nginx搭建自己的web服务器,后台程序专门部署在一台服务器上(我们之前公司就有三套环境,开发/测试/生产),这样做的好处是 1.前端代码基本都是静态文件,重启一次很快,也就几秒钟时间. ...

  6. PySpider 框架爬虫错误 HTTP 599: SSL certificate problem: unable to get local issuer certificate解决方案

    首先pyspider all启动pyspider的所有服务,然后访问http://localhost:5000创建一个爬虫任务:taobaomm,点开任务链接编辑http://localhost:50 ...

  7. 屏幕录像大师如何把LXE文件转换为EXE文件

    EXE 和 LXE 实际上是同一种格式,文件大小完全相同,可以快速相互转换.区别是EXE复制到其它电脑上可以直接播放,LXE需要播放器播放,我们提供LXE播放器,而且是完全免费的.EXE的好处是复制到 ...

  8. docker中的link

    一.查看容器的详细情形 docker inspect 容器id/名称 二.为什么要用link 容器每次重启时,ip都会变动,这不利于前端引用中连接数据库. 三.link docker run -p 8 ...

  9. windows下at命令使用详解

    T命令是Windows XP中内置的命令,它也可以媲美Windows中的“计划任务”,而且在计划的安排.任务的管理.工作事务的处理方面,AT命令具有更强大更神通的功能.AT命令可在指定时间和日期.在指 ...

  10. 小程序数组合并concat

      arr1=arr1.concat(arr2)   文章来源:刘俊涛的博客 地址:http://www.cnblogs.com/lovebing 欢迎关注,有问题一起学习欢迎留言.评论.