`
smallTengGer
  • 浏览: 34335 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

No qualifying bean of type 'com.my.mapper.UserMapper'

阅读更多

 Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.my.mapper.UserMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1474)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1102)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1064)

at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585)

... 58 more

 

 

在使用mybatis的时候出现这个错误,首先检查有没有在Spring.xml配置文件中添加mybatis的动态扫描。

最重要的是看下信息有没有写错,我的mapper的包是com.my.mapper。但是不小心多在后面写了个r。导致出现上面的错误,花费了不少时间。

<!-- MyBatis 动态扫描  -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
    <property name="basePackage" value="com.my.mapperr"/>
</bean>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics