在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以上即可
<!-- 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>
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。
如对本文有疑问, 点击进行留言回复!!
多个JAVA版本导致的JAVA_HOME is set to an invalid directory
ARouter简易ARouter+手动组件化跳转Module应用总结
【bug记录】android:Program type already present: android.support.v4.app.INotificationSideChannel
网友评论