我是靠谱客的博主 飘逸西装,最近开发中收集的这篇文章主要介绍springboot引用gson包出现的问题,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

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>

最后

以上就是飘逸西装为你收集整理的springboot引用gson包出现的问题的全部内容,希望文章能够帮你解决springboot引用gson包出现的问题所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(58)

评论列表共有 0 条评论

立即
投稿
返回
顶部