【spring Boot+Mybaits】记一次Mapeer扫不到的情况

搭建新项目用的是Spring Boot来做的,没有用Cloud,当然这个并不重要,重要的是用Mybatis的代码生成器生成的POJO和Mapper 做全局的,而在某个模块中启动报错。如下代码所示:

***************************
APPLICATION FAILED TO START
***************************

Description:

Field xxxBrandMapper in xxx.xxx.xxx.service.impl.BrandServiceImpl required a bean of type 'xxx.xxx.xxx.mapper.PmsBrandMapper' that could not be found.

The injection point has the following annotations:
	- @org.springframework.beans.factory.annotation.Autowired(required=true)


Action:

Consider defining a bean of type 'xxx.xxx.xxx.mapper.PmsBrandMapper' in your configuration.

看到这个报错就慌了,那么久没有写代码,一写代码来个错,首先我检查了application.yml的mybatis.mapper-location ,这个配置,发现也没有写错,还是报错 再次百度,有很多解决方案而且搜到的版本也是很多且杂。但是在Mapper里面加个@Mapper注解就能够启动,而且不用那么费力,但是Mybatis生成了大概30个,不可能一个个去添加这个@Mapper注解吧。最后想到用一个配置类来做这个 直接用@MaaperScan去扫描 就能够成功启动。

当然这个小问题 百度一下是非常的多解决方法,主要是看你用哪种方法,这篇只是为了记录一下报错的复盘流程。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值