Springboot中使用GSON报错 An attempt was made to call the method com.google.gson.GsonBuilder.setLenient

错误如下:

 

Description:

An attempt was made to call the method com.google.gson.GsonBuilder.setLenient()Lcom/google/gson/GsonBuilder; but it does not exist. Its class, com.google.gson.GsonBuilder, is available from the following locations:

  ......
 

这种情况是GSON依赖版本不对,换成2.6以上版本即可,如:

 

<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
   <groupId>com.google.code.gson</groupId>
   <artifactId>gson</artifactId>
   <version>2.6.2</version>
</dependency>

posted on 2022-11-08 07:36  小目标青年  阅读(184)  评论(0编辑  收藏  举报