springboot引用gson包出现的问题

mac2026-09-30  6

springboot引用gson包后启动时出现下面错误信息

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:/Users/xu/.m2/repository/com/google/code/gson/gson/2.2.2/gson-2.2.2.jar!/com/google/gson/GsonBuilder.class     jar:file:/Users/xu/work/wrapper/libs/gson-2.2.2.jar!/com/google/gson/GsonBuilder.class

It was loaded from the following location:

    file:/Users/xu/.m2/repository/com/google/code/gson/gson/2.2.2/gson-2.2.2.jar

Action:

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

Process finished with exit code 1  

解决办法:

将pom中gson版本改完2.6解决。

<dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>2.6</version> </dependency>
最新回复(0)