java.lang.NoSuchMethodError:com.google.common.base.Preconditions [英] java.lang.NoSuchMethodError: com.google.common.base.Preconditions
问题描述
我收到此错误
java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:124)
at org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:32)
at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:137)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:339)
at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:88)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:123)
我为社交媒体构建机器人,所以我使用Selenium库,并且机器人在Java应用程序上正常工作,但是当我将代码复制到Web应用程序时,我有一个Servlet监听我的Android应用程序,当我运行servlet,并且servlet调用使用Selenium的bot的代码时,它会抛出该行的错误
Im building a bot for social media , so Im using Selenium libraries, and the bot works fine on a Java Application , but when I copy the code to a Web Application where I have a Servlet listening to my Android application , when I run the servlet , and the servlet calls the code of the bot that use Selenium, it throws that error when it comes to that line
System.setProperty("webdriver.chrome.driver", "C:\\Users\\manue\\OneDrive\\Escritorio\\chromedriver.exe");
driver = new ChromeDriver();
我读过它可能是我所拥有的番石榴版本,但我的版本是guava已更新,我不知道为什么我会收到此错误。
I had read that it can be becouse of the version of guava that I have , but my version of guava is updated , and I dont know why Im getting this error.
在我的maven pom.xml中,我有这样的依赖关系
In my maven pom.xml I have the dependencies like this
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.10.0</version>
</dependency>
这里有我项目结构的截图。
我项目的截图
Here there is a screenshot of the structure of my project. screenshot of my project
推荐答案
当我从lib路径中删除Google Collections jar时,我找到了一个可能相关的错误消息的解决方案。
I found a solution to a possibly related error message when I removed the Google Collections jar from the lib path.
(来源)
这篇关于java.lang.NoSuchMethodError:com.google.common.base.Preconditions的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!