Spring Boot中mybatis:Field peopleInfoMapper in ‘**’that could not be found.

在搭建使用spring boot编译时出现了如下的问题:

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2018-06-21 09:59:29.486 ERROR 8544 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 
***************************
APPLICATION FAILED TO START
***************************
Description:

Field peopleInfoMapper in com.exa.demo2.Controller.PeopleController required a bean of type 'com.exa.demo2.Mapper.PeopleInfoMapper' that could not be found.

Action: 

Consider defining a bean of type 'com.exa.demo2.Mapper.PeopleInfoMapper' in your configuration.

Process finished with exit code 1.

SpringBoot启动失败,告诉我Bean配置失败,楼主看了看  该用的注解都用上了  这是咋的回事嘞?

PeopleMapper:


Controller:


后来在网上查资料说要用@Mapper注解,才能把问题解决。

解决方案1:使用@Mapper注解


解决方案2:使用@MapperScan注解启动类Demo2Application


这样问题就可以顺利解决了。

原因:在mybatis-spring-boot-autoconfigure的jar包中有一个类 MybatisAutoConfiguration,在这个类中的registerBeanDefinitions方法告诉了我们


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值