admin管理员组文章数量:1566351
使用Mybatis报错Error creating bean with name 'com.yg.mybatisgenerator.springbootTest.GeneratorTest': Unsatisfied dependency expressed through field 'xxxMapper'
- 问题背景
- 解决方案
- 心得
- Lyric:篮筐变得好高
‘com.yg.mybatisgenerator.springbootTest.GeneratorTest’: Unsatisfied dependency expressed through field
‘xxxMapper’)
问题背景
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name
'com.yg.mybatisgenerator.springbootTest.GeneratorTest': Unsatisfied dependency expressed through field
'generatorRecordMapper'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type
'com.yg.mybatisgenerator.dao.mysql.GeneratorRecordMapper' available: expected at least 1 bean which
qualifies as autowire candidate. Dependency annotations:
{@org.springframework.beans.factory.annotation.Autowired(required=true)}
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.yg.mybatisgenerator.dao.mysql.GeneratorRecordMapper' 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:1799)
解决方案
1 因为找不到mapper所在的地方,在启动类上添加mapper所在的路径,添加扫描注解@MapperScan
@MapperScan("com/data/dao/mysql")
@SpringBootApplication
心得
- @MapperScan就是去扫描mapper映射文件进行匹配
作为程序员第 44 篇文章,每次写一句歌词记录一下,看看人生有几首歌的时间,wahahaha …
Lyric:篮筐变得好高
本文标签: 报错解决方案UnsatisfiedMyBatisDependency
版权声明:本文标题:使用Mybatis报错Unsatisfied dependency expressed through field ‘xxxMapper‘解决方案 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/xitong/1725805069a1043923.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论