相关文章推荐
个性的单杠  ·  java ...·  1 周前    · 
强悍的斑马  ·  Android判断版本号 - J依情 - 博客园·  2 月前    · 
豪气的人字拖  ·  配置 nginx ...·  6 月前    · 
淡定的乒乓球  ·  当前不会命中断点,还没有为该文档加载任何符号 ...·  8 月前    · 
慷慨大方的炒饭  ·  matlab等高线填充 - CSDN文库·  8 月前    · 
细心的打火机  ·  Pytorch DeepSpeed论文 ...·  1 年前    · 
Code  ›  spring-boot:The following method did not exist: com.google.gson.GsonBuilder.setLenient()开发者社区
gson
https://cloud.tencent.com/developer/article/2152497
要出家的煎饼果子
1 年前
作者头像
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 string转对象数组_mob64ca12d32849的技术博客_
1 周前
强悍的斑马  ·  Android判断版本号 - J依情 - 博客园
2 月前
豪气的人字拖  ·  配置 nginx 访问资源目录,nginx配置 root 与 alias 的区别 - 一文搞懂 - 博客园
6 月前
淡定的乒乓球  ·  当前不会命中断点,还没有为该文档加载任何符号_我要做独立游戏的技术博客_51CTO博客
8 月前
慷慨大方的炒饭  ·  matlab等高线填充 - CSDN文库
8 月前
细心的打火机  ·  Pytorch DeepSpeed论文 deepsort pytorch_mob6454cc74c0fc的技术博客_51CTO博客
1 年前
今天看啥   ·   Py中国   ·   codingpro   ·   小百科   ·   link之家   ·   卧龙AI搜索
删除内容请联系邮箱 2879853325@qq.com
Code - 代码工具平台
© 2024 ~ 沪ICP备11025650号