相关文章推荐
奋斗的乒乓球  ·  Java使用Jackson和Gson将JSO ...·  3 周前    · 
没读研的奔马  ·  [ Android ] ...·  3 月前    · 
好帅的排球  ·  【合集】《血源诅咒》如何加入圣诗班_哔哩哔哩 ...·  1 年前    · 
安静的柚子  ·  c++ ...·  1 年前    · 
爱吹牛的瀑布  ·  MySQL如何获取JSON串的值_mysql ...·  1 年前    · 
打篮球的口罩  ·  奥特曼:泰迦三重形态,看上去是合体,其实是增 ...·  1 年前    · 
Code  ›  spring-boot:The following method did not exist: com.google.gson.GsonBuilder.setLenient()开发者社区
gson
https://cloud.tencent.com/developer/article/2152497
要出家的煎饼果子
2 年前
作者头像
10km
0 篇文章

spring-boot:The following method did not exist: com.google.gson.GsonBuilder.setLenient()

前往专栏
腾讯云
开发者社区
文档 意见反馈 控制台
首页
学习
活动
专区
工具
TVP
文章/答案/技术大牛
发布
首页
学习
活动
专区
工具
TVP
返回腾讯云官网
社区首页 > 专栏 > 10km的专栏 > spring-boot:The following method did not exist: com.google.gson.GsonBuilder.setLenient()

spring-boot:The following method did not exist: com.google.gson.GsonBuilder.setLenient()

作者头像
10km
发布 于 2022-11-06 09:47:03
385 0
发布 于 2022-11-06 09:47:03
举报

今天启动我的spring-boot项目时报了如下的错误:

***************************
APPLICATION FAILED TO START
***************************
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:/J:/maven_repository/com/google/code/gson/gson/2.2.4/gson-2.2.4.jar!/com/google/gson/GsonBuilder.class
The class hierarchy was loaded from the following locations:
    com.google.gson.GsonBuilder: file:/J:/maven_repository/com/google/code/gson/gson/2.2.4/gson-2.2.4.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of com.google.gson.GsonBuilder

意思就是找不到 com.google.gson.GsonBuilder.setLenient() 方法, gson-2.2.4.jar 中的 GsonBuilder 类确没有这个方法。初步判断这应该是gson库的版本不匹配造成的

google上找了一下,找到stackoverflow上的如下帖子: 《Why do I get Gson builder error when starting a Spring Boot application?》 知道了原因, org.springframework.boot:spring-boot-autoconfigure:2.5.6 包中的GsonAutoConfiguration类中引用了 com.google.gson.GsonBuilder.setLenient() ‘方法,应该是较高的gson版本。 我的项目中引用的 org.apache.phoenix:phoenix-core:4.14.0-cdh5.14.2 库也依赖gson 2.2.4库,替换了 spring-boot-autoconfigure 中引用的gson高版本,导致错误发生。

 
推荐文章
奋斗的乒乓球  ·  Java使用Jackson和Gson将JSON的ArrayNode转为ArrayList-开发者社区-阿里云
3 周前
没读研的奔马  ·  [ Android ] ConstraintSet 으로 유동적으로 Constraint 변경하기 : 네이버 블로그
3 月前
好帅的排球  ·  【合集】《血源诅咒》如何加入圣诗班_哔哩哔哩_bilibili
1 年前
安静的柚子  ·  c++ SetConsoleMode函数与GetConsoleMode-CSDN博客
1 年前
爱吹牛的瀑布  ·  MySQL如何获取JSON串的值_mysql select 获取字段json内容中指定key value-CSDN博客
1 年前
打篮球的口罩  ·  奥特曼:泰迦三重形态,看上去是合体,其实是增幅了泰迦的炎之力_网易订阅
1 年前
今天看啥   ·   Py中国   ·   codingpro   ·   小百科   ·   link之家   ·   卧龙AI搜索
删除内容请联系邮箱 2879853325@qq.com
Code - 代码工具平台
© 2024 ~ 沪ICP备11025650号