报错内容,只展示一行吧

2023-05-25 11:08:19.058 [172.31.0.23] [main] WARN  tk.mybatis.spring.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'xxxMapper' and 'xx.xx.mapper.xxMapper' mapperInterface. Bean already defined with the same name!

解决思路:
1、全局搜索 @MapperScan 注解是否重复,如果有,注释一个
2、如果启动类中有@SpringBootApplication、@MapperScan({ “com.xxx.mapper” })这两个注解,同时你的xxMapper接口中有@Mapper注解,那么就把xxMapper接口中的@Mapper注解去掉。 有人说注释@MapperScan({ “com.xxx.mapper” })这个,我试了一下,不行。

原因:
重复注入了,@MapperScan注入了一次,@SpringBootApplication+@Mapper又注入了一次

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐