dwarf.han
dwarf.han

Reputation: 31

spring boot failed with gson 2.2.4

After running SpringApplication, I got this error.

when i used gson 2.8.2, below error not showing.

However, due to dependency libraries in my project I should use gson 2.2.4.

How to run spring boot application with gson 2.2.4?

***************************
APPLICATION FAILED TO START
***************************

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:

    jar:file:/D:/Han/Documents/projects/java/maven/repository/gson/gson/2.2.4/gson-2.2.4.jar!/com/google/gson/GsonBuilder.class
    jar:file:/D:/Han/Documents/projects/java/maven/repository/com/google/code/gson/gson/2.2.4/gson-2.2.4.jar!/com/google/gson/GsonBuilder.class

It was loaded from the following location:

    file:/D:/Han/Documents/projects/java/maven/repository/gson/gson/2.2.4/gson-2.2.4.jar


Action:

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

Upvotes: 1

Views: 1244

Answers (1)

Parameshwar
Parameshwar

Reputation: 966

Had similar issue following latest mvn package of gson resolved my problem in Spring Boot

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

Upvotes: 1

Related Questions