问题描述
在 TestNg 中运行 selenium 脚本时,我遇到了以下错误线程main"java.lang.NoClassDefFoundError 中的异常:com/google/gson/JsonParseException".如何解决此错误?
I have encountered the following error "Exception in thread "main" java.lang.NoClassDefFoundError: com/google/gson/JsonParseException", when running selenium script in TestNg. How to resolve this error?
推荐答案
我之前遇到过同样的NoClassDefFoundError:com/google/gson/JsonParseException"错误.这是由于在我的包中添加了selenium-java-2.53.0"jar 文件造成的.
I have came across the same "NoClassDefFoundError:com/google/gson/JsonParseException" error before. This was caused by the addition of "selenium-java-2.53.0" jar file in my package.
我删除了这个 jar 文件并刷新了我的项目并再次运行.之后在那里工作得很好.
I removed this jar file and refreshed my project and ran again. It was working fine there after.
你也可以试试.jar 文件的版本可能不同,但删除它应该可以完成工作.
You can try the same. The version of the jar file may differ but removing it should do the job.
干杯.
这篇关于线程“main"中的异常java.lang.NoClassDefFoundError: com/google/gson/JsonParseExceptiong的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!