搭建新项目用的是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去扫描 就能够成功启动。
当然这个小问题 百度一下是非常的多解决方法,主要是看你用哪种方法,这篇只是为了记录一下报错的复盘流程。