Springboot整合Gson報(bào)錯(cuò)問題解決過程
在Springboot 中依賴Gson,項(xiàng)目啟動(dòng)時(shí)報(bào)錯(cuò):
***************************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.classIt was loaded from the following location: file:/D:/8_maven/mvnrepo/com/google/code/gson/gson/2.5/gson-2.5.jarAction:Correct the classpath of your application so that it contains a single, compatible version of com.google.gson.GsonBuilder
解決辦法:
將pom中依賴的Gson版本更換為2.6以上即可
<!-- 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>
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. Java類加載機(jī)制實(shí)現(xiàn)步驟解析2. 如何清空python的變量3. JAMon(Java Application Monitor)備忘記4. Spring security 自定義過濾器實(shí)現(xiàn)Json參數(shù)傳遞并兼容表單參數(shù)(實(shí)例代碼)5. IntelliJ IDEA設(shè)置默認(rèn)瀏覽器的方法6. Python TestSuite生成測(cè)試報(bào)告過程解析7. Python 如何展開嵌套的序列8. 增大python字體的方法步驟9. Python os庫常用操作代碼匯總10. 在JSP中使用formatNumber控制要顯示的小數(shù)位數(shù)方法
