SpringBoot集成第三方jar包启动报错GsonBuilder.setLenient()

SpringBoot集成第三方jar包启动报错

背景

对接某第三方jar包,集成到SpringBoot里面跑测试demo,启动报错

报错BUG

2020-03-27 15:50:07.084 [main] DEBUG o.s.b.d.LoggingFailureAnalysisReporter - Application failed to start due to an exception
java.lang.NoSuchMethodError: com.google.gson.GsonBuilder.setLenient()Lcom/google/gson/GsonBuilder;
Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    java.lang.invoke.MethodHandleNatives.resolve(Native Method)

The following method did not exist:

    com.google.gson.GsonBuilder.setLenient()Lcom/google/gson/GsonBuilder;

The method's class, com.google.gson.GsonBuilder, is available from the following locations:

    jar:file:/D:/maven_repository/cn/coralglobal/coupang-open-api/1.0.13/coupang-open-api-1.0.13.jar!/com/google/gson/GsonBuilder.class

It was loaded from the following location:

    file:/D:/maven_repository/cn/coralglobal/coupang-open-api/1.0.13/coupang-open-api-1.0.13.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of com.google.gson.GsonBuilder

排查问题

查看了很多资料说是 gson版本冲突什么的,我排除 spring-boot-starter-web 里面的gson还是报错

解决方案

@SpringBootApplication(exclude = {GsonAutoConfiguration.class})

参考链接

SpringBoot排除自动装配某个class来解决jar包冲突
https://my.oschina.net/wangxu3655/blog/3100054

链接地址 link

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值