Springboot中使用GSON报错 An attempt was made to call the method com.google.gson.GsonBuilder.setLenient
最新推荐文章于 2023-03-09 14:25:31 发布
小目标青年
最新推荐文章于 2023-03-09 14:25:31 发布
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>
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 a...
解决An
att
empt
was made to call a
method
that does not exist. The
att
empt
was made from the following location:
最近在学习springcloud,搭建初始环境的时候遇到了这个问题, 在启动
SpringBoot
的时候不成功,弹出如下错误
Description:
An
att
empt
was made to call a
method
that does not exist. The
att
em
Caused by:
com
.
google
.
gson
.JsonSyntaxException: 1534467411000
at
com
.
google
.
gson
.internal.bind.DateTypeAdapter.deserializeToDate(DateTypeAdapter.java:74)
使用
GSON
报错
Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
使用
GSON
报错
,是因为数据类型转化错误。
public String cuttingDataSendBuyerMessage(String messageData) {
String result = "暂无消息";
Duplicate class
com
.
google
.
gson
.internal.bind.TypeAdapters$9 found in modules
gson
-2.7 (
gson
-2.7.jar) and
gson
-2.8.7 (
com
.
google
.code.
gson
:
gson
:2.8.7)
Duplicate class
com
.
google
.
gson
.internal.bind.TypeAdapters$EnumTypeAdapter found in modules
gson
-2.7 (gs.
An
att
empt
was made to call the
method
org.springframework.boot...RedisSessionConfiguration 的解决办法
com
.
google
.
gson
.
gson
的依赖是指
使用
Gson
库时需要在项目
中
添加的依赖项。
Gson
是一个Java库,用于将Java对象转换为JSON格式,或将JSON格式转换为Java对象。在
使用
Gson
时,需要在项目的build.gradle文件
中
添加以下依赖项:
dependencies {
implementation '
com
.
google
.code.
gson
:
gson
:2.8.6'
这样就可以在项目
中
使用
Gson
库了。
Code_Fish0.0: