Springboot中使用GSON报错 An attempt was made to call the method com.google.gson.GsonBuilder.setLenient
原创
©著作权归作者所有:来自51CTO博客作者小目标青年来也的原创作品,请联系作者获取转载授权,否则将追究法律责任
错误如下:
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>