這篇文章主要為大家展示了出現(xiàn)Springboot整合Gson報錯問題怎么辦,內(nèi)容簡而易懂,希望大家可以學(xué)習(xí)一下,學(xué)習(xí)完之后肯定會有收獲的,下面讓小編帶大家一起來看看吧。
成都創(chuàng)新互聯(lián)公司于2013年開始,先為項城等服務(wù)建站,項城等地企業(yè),進行企業(yè)商務(wù)咨詢服務(wù)。為項城企業(yè)網(wǎng)站制作PC+手機+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問題。
在Springboot 中依賴Gson,項目啟動時報錯:
*************************** APPLICATION FAILED TO START *************************** 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:/D:/8_maven/mvnrepo/com/google/code/gson/gson/2.5/gson-2.5.jar!/com/google/gson/GsonBuilder.class It was loaded from the following location: file:/D:/8_maven/mvnrepo/com/google/code/gson/gson/2.5/gson-2.5.jar Action: Correct the classpath of your application so that it contains a single, compatible version of com.google.gson.GsonBuilder
解決辦法:
將pom中依賴的Gson版本更換為2.6以上即可
com.google.code.gson gson 2.8.6
以上就是關(guān)于出現(xiàn)Springboot整合Gson報錯問題怎么辦的內(nèi)容,如果你們有學(xué)習(xí)到知識或者技能,可以把它分享出去讓更多的人看到。