当前位置: 移动技术网 > IT编程>开发语言>Java > Springboot整合Gson报错问题解决过程

Springboot整合Gson报错问题解决过程

2020年06月13日  | 移动技术网IT编程  | 我要评论

在springboot 中依赖gson,项目启动时报错:

***************************
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:/d:/8_maven/mvnrepo/com/google/code/gson/gson/2.5/gson-2.5.jar!/com/google/gson/gsonbuilder.class

it was loaded from the following location:

  file:/d:/8_maven/mvnrepo/com/google/code/gson/gson/2.5/gson-2.5.jar


action:

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

解决办法:

将pom中依赖的gson版本更换为2.6以上即可

<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
  <groupid>com.google.code.gson</groupid>
  <artifactid>gson</artifactid>
  <version>2.8.6</version>
</dependency>

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网