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

电玩女神 2022-04-23 18:28 450阅读 0赞

错误如下:

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以上版本即可,如:

  1. <!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
  2. <dependency>
  3. <groupId>com.google.code.gson</groupId>
  4. <artifactId>gson</artifactId>
  5. <version>2.6.2</version>
  6. </dependency>

发表评论

表情:
评论列表 (有 0 条评论,450人围观)

还没有评论,来说两句吧...

相关阅读