解决SpringBoot工程启动报错mapperInterface. Bean already defined with the same name!的问题总结
2、如果启动类中有@SpringBootApplication、@MapperScan({ “com.xxx.mapper” })这两个注解,同时你的xxMapper接口中有@Mapper注解,那么就把xxMapper接口中的@Mapper注解去掉。有人说注释@MapperScan({ “com.xxx.mapper” })这个,我试了一下,不行。重复注入了,@MapperScan注入了一次,@S
·
报错内容,只展示一行吧
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又注入了一次
更多推荐
已为社区贡献4条内容
所有评论(0)