解决WARN:Skipping MapperFactoryBean with name ‘xxxBeanMapper‘ and ‘com.xxx.xxxMapper‘ mapperInterface

本文主要是介绍解决WARN:Skipping MapperFactoryBean with name ‘xxxBeanMapper‘ and ‘com.xxx.xxxMapper‘ mapperInterface,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

问题描述

报错信息:Skipping MapperFactoryBean with name ‘xxxMapper’ and ‘xxx.xxx.xxx.mapper.xxxxxMapper’ nterface. Bean already defined with the same name!
若依项目启动时控制台打印出以下WARN 日志,Bean already defined with the same name日志信息大意就是Bean重复注入

 WARN  org.mybatis.spring.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'archiveBeanMapper' and 'com.cxstar.business.repository.mapper.ArchiveBeanMapper' mapperInterface. Bean already defined with the same name! WARN  org.mybatis.spring.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'badWordBeanMapper' and 'com.cxstar.business.repository.mapper.BadWordBeanMapper' mapperInterface. Bean already defined with the same name! WARN  org.mybatis.spring.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'bookMapper' and 'com.cxstar.business.repository.mapper.BookMapper' mapperInterface. Bean already defined with the same name! WARN  org.mybatis.spring.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'clcViewMapper' and 'com.cxstar.business.repository.mapper.ClcViewMapper' mapperInterface. Bean already defined with the same name! WARN  org.mybatis.spring.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'ebookCollectionMapper' and 'com.cxstar.business.repository.mapper.EbookCollectionMapper' mapperInterface. Bean already defined with the same name! WARN  org.mybatis.spring.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'ebookCollectionUnitMapper' and 'com.cxstar.business.repository.mapper.EbookCollectionUnitMapper' mapperInterface. Bean already defined with the same name! WARN  org.mybatis.spring.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'esPushMapper' and 'com.cxstar.business.repository.mapper.EsPushMapper' mapperInterface. Bean already defined with the same name! 

问题分析

该问题目前还没有发现对项目有影响,但是希望排除掉该问题,因此需要排查问题原因
首先提示Bean重复注入,因此从注入Bean的地方开始排查
当前若依项目使用了自带的mybatis,以及后引入的mybatisplus,先排查这两的配置类的扫描文件是否有路径重复

Mybatis的配置类

/*** 程序注解配置*/
@Configuration
// 表示通过aop框架暴露该代理对象,AopContext能够访问
@EnableAspectJAutoProxy(exposeProxy = true)
// 指定要扫描的Mapper类的包的路径
@MapperScan("com.zqtest.**.mapper")
//@MapperScans({@MapperScan(value = "com.cxstar.system.mapper"),@MapperScan(value = "com.cxstar.quartz.mapper")})
public class ApplicationConfig {//...
}

MybatisPlus的配置类

@EnableTransactionManagement
@Configuration
@MapperScans({@MapperScan(value = "com.zqtest.**.repository.mapper")})
public class MybatisPlusConfig {//...
}

问题就在于Mybatis@MapperScan路径已经包含了MybatisPlus的@MapperScan路径,无论谁先被Spring实例化都会导致最后一个被实例化时报出bean重复注入的警告

问题解决

如果项目中同时使用了Mybatis和MybatisPlus,在各自配置类上应配置详细的要扫描的Mapper类的包的路径,而不是使用‘**’等导致扫描路径重复。
在这里插入图片描述

这篇关于解决WARN:Skipping MapperFactoryBean with name ‘xxxBeanMapper‘ and ‘com.xxx.xxxMapper‘ mapperInterface的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/158214

相关文章

Nginx 配置跨域的实现及常见问题解决

《Nginx配置跨域的实现及常见问题解决》本文主要介绍了Nginx配置跨域的实现及常见问题解决,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来... 目录1. 跨域1.1 同源策略1.2 跨域资源共享(CORS)2. Nginx 配置跨域的场景2.1

qt5cored.dll报错怎么解决? 电脑qt5cored.dll文件丢失修复技巧

《qt5cored.dll报错怎么解决?电脑qt5cored.dll文件丢失修复技巧》在进行软件安装或运行程序时,有时会遇到由于找不到qt5core.dll,无法继续执行代码,这个问题可能是由于该文... 遇到qt5cored.dll文件错误时,可能会导致基于 Qt 开发的应用程序无法正常运行或启动。这种错

SpringBoot排查和解决JSON解析错误(400 Bad Request)的方法

《SpringBoot排查和解决JSON解析错误(400BadRequest)的方法》在开发SpringBootRESTfulAPI时,客户端与服务端的数据交互通常使用JSON格式,然而,JSON... 目录问题背景1. 问题描述2. 错误分析解决方案1. 手动重新输入jsON2. 使用工具清理JSON3.

MySQL 设置AUTO_INCREMENT 无效的问题解决

《MySQL设置AUTO_INCREMENT无效的问题解决》本文主要介绍了MySQL设置AUTO_INCREMENT无效的问题解决,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参... 目录快速设置mysql的auto_increment参数一、修改 AUTO_INCREMENT 的值。

关于跨域无效的问题及解决(java后端方案)

《关于跨域无效的问题及解决(java后端方案)》:本文主要介绍关于跨域无效的问题及解决(java后端方案),具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录通用后端跨域方法1、@CrossOrigin 注解2、springboot2.0 实现WebMvcConfig

Go语言中泄漏缓冲区的问题解决

《Go语言中泄漏缓冲区的问题解决》缓冲区是一种常见的数据结构,常被用于在不同的并发单元之间传递数据,然而,若缓冲区使用不当,就可能引发泄漏缓冲区问题,本文就来介绍一下问题的解决,感兴趣的可以了解一下... 目录引言泄漏缓冲区的基本概念代码示例:泄漏缓冲区的产生项目场景:Web 服务器中的请求缓冲场景描述代码

解决JSONField、JsonProperty不生效的问题

《解决JSONField、JsonProperty不生效的问题》:本文主要介绍解决JSONField、JsonProperty不生效的问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑... 目录jsONField、JsonProperty不生效javascript问题排查总结JSONField

github打不开的问题分析及解决

《github打不开的问题分析及解决》:本文主要介绍github打不开的问题分析及解决,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、找到github.com域名解析的ip地址二、找到github.global.ssl.fastly.net网址解析的ip地址三

RedisTemplate默认序列化方式显示中文乱码的解决

《RedisTemplate默认序列化方式显示中文乱码的解决》本文主要介绍了SpringDataRedis默认使用JdkSerializationRedisSerializer导致数据乱码,文中通过示... 目录1. 问题原因2. 解决方案3. 配置类示例4. 配置说明5. 使用示例6. 验证存储结果7.

Swagger在java中的运用及常见问题解决

《Swagger在java中的运用及常见问题解决》Swagger插件是一款深受Java开发者喜爱的工具,它在前后端分离的开发模式下发挥着重要作用,:本文主要介绍Swagger在java中的运用及常... 目录前言1. Swagger 的主要功能1.1 交互式 API 文档1.2 客户端 SDK 生成1.3