xstream.mapper和mybatisplus.core.mapper冲突

报错信息
[com.baomidou.mybatisplus.core.mapper.Mapper] conflicts with existing, non-compatible bean definition of same name and class [com.thoughtworks.xstream.mapper.Mapper]
在这里插入图片描述
问题描述:
由于一些原因,需要将该SpringBoot的程序,注册到指定版本的微服务中
SpringBoot 版本:2.3.10.RELEASE
springCloud 版本:Hoxton.SR10
依赖如下:

<!-- eureka-client -->
<dependency>
   	<groupId>org.springframework.cloud</groupId>
   	<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<!-- eureka-client -->
<dependency>
     <groupId>org.springframework.cloud</groupId>
     <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
     <exclusion>
         <groupId>com.thoughtworks.xstream</groupId>
         <artifactId>xstream</artifactId>
     </exclusion>
</dependency>

发现出现如上错误,尝试将冲突的xstream排除不与mybatisplus冲突,但是无法解决问题,
报错:Error creating bean with name ‘scopedTarget.eurekaClient’ defined in class path resource。
进一步往下查看日志,是因为找不到com.thoughtworks.xstream,因此不能单纯的排除xstream。
在这里插入图片描述
备注:如下是正常启动时的日志信息,可以看到eureka(至少这个版本)是需要xstream的,因此不能直接进行排除
在这里插入图片描述

接着,只能去看下这个项目原本的mybatis-plus是什么怎么配置的,可以看到,扫包中的配置是匹配com开始,mappe结尾的包目录

@SpringBootConfiguration
@MapperScan(basePackages = {"com.**.mapper"})
@EnableTransactionManagement
public class MybatisConfig{
	//省略其他配置
}
//com.**.mapper该配置能识别到如下两个
com.thoughtworks.xstream.mapper.Mapper
com.baomidou.mybatisplus.core.mapper.Mapper

知道问题就知道好改了,这里com开头的范围太大了,我们可以修改一下,限定下范围,例如添加完整的根路径
在这里插入图片描述

@MapperScan(basePackages = {"com.equp.evaluate.**.mapper"})

至此,问题得以解决

  • 8
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值