解决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

相关文章

解决IDEA报错:编码GBK的不可映射字符问题

《解决IDEA报错:编码GBK的不可映射字符问题》:本文主要介绍解决IDEA报错:编码GBK的不可映射字符问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录IDEA报错:编码GBK的不可映射字符终端软件问题描述原因分析解决方案方法1:将命令改为方法2:右下jav

MyBatis模糊查询报错:ParserException: not supported.pos 问题解决

《MyBatis模糊查询报错:ParserException:notsupported.pos问题解决》本文主要介绍了MyBatis模糊查询报错:ParserException:notsuppo... 目录问题描述问题根源错误SQL解析逻辑深层原因分析三种解决方案方案一:使用CONCAT函数(推荐)方案二:

IntelliJ IDEA 中配置 Spring MVC 环境的详细步骤及问题解决

《IntelliJIDEA中配置SpringMVC环境的详细步骤及问题解决》:本文主要介绍IntelliJIDEA中配置SpringMVC环境的详细步骤及问题解决,本文分步骤结合实例给大... 目录步骤 1:创建 Maven Web 项目步骤 2:添加 Spring MVC 依赖1、保存后执行2、将新的依赖

Spring 中的循环引用问题解决方法

《Spring中的循环引用问题解决方法》:本文主要介绍Spring中的循环引用问题解决方法,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧... 目录什么是循环引用?循环依赖三级缓存解决循环依赖二级缓存三级缓存本章来聊聊Spring 中的循环引用问题该如何解决。这里聊

关于MongoDB图片URL存储异常问题以及解决

《关于MongoDB图片URL存储异常问题以及解决》:本文主要介绍关于MongoDB图片URL存储异常问题以及解决方案,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐... 目录MongoDB图片URL存储异常问题项目场景问题描述原因分析解决方案预防措施js总结MongoDB图

SpringBoot项目中报错The field screenShot exceeds its maximum permitted size of 1048576 bytes.的问题及解决

《SpringBoot项目中报错ThefieldscreenShotexceedsitsmaximumpermittedsizeof1048576bytes.的问题及解决》这篇文章... 目录项目场景问题描述原因分析解决方案总结项目场景javascript提示:项目相关背景:项目场景:基于Spring

解决Maven项目idea找不到本地仓库jar包问题以及使用mvn install:install-file

《解决Maven项目idea找不到本地仓库jar包问题以及使用mvninstall:install-file》:本文主要介绍解决Maven项目idea找不到本地仓库jar包问题以及使用mvnin... 目录Maven项目idea找不到本地仓库jar包以及使用mvn install:install-file基

最详细安装 PostgreSQL方法及常见问题解决

《最详细安装PostgreSQL方法及常见问题解决》:本文主要介绍最详细安装PostgreSQL方法及常见问题解决,介绍了在Windows系统上安装PostgreSQL及Linux系统上安装Po... 目录一、在 Windows 系统上安装 PostgreSQL1. 下载 PostgreSQL 安装包2.

Mysql如何解决死锁问题

《Mysql如何解决死锁问题》:本文主要介绍Mysql如何解决死锁问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录【一】mysql中锁分类和加锁情况【1】按锁的粒度分类全局锁表级锁行级锁【2】按锁的模式分类【二】加锁方式的影响因素【三】Mysql的死锁情况【1

SpringBoot内嵌Tomcat临时目录问题及解决

《SpringBoot内嵌Tomcat临时目录问题及解决》:本文主要介绍SpringBoot内嵌Tomcat临时目录问题及解决,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,... 目录SprinjavascriptgBoot内嵌Tomcat临时目录问题1.背景2.方案3.代码中配置t