java.lang.NoClassDefFoundError:com/google/common/collect/ImmutableMap,同时在Java Selenium中将WebDriver与Maven依赖项一起使用 [英] java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableMap while using WebDriver with Maven Dependencies in Java Selenium

查看:414
本文介绍了java.lang.NoClassDefFoundError:com/google/common/collect/ImmutableMap,同时在Java Selenium中将WebDriver与Maven依赖项一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  1. 这是driver=new ChromeDriver();行之后的代码的一部分,它给我我用sysout检查的错误,错误在2中,那么我使用Maven的经验不是很好,但是我正在检查我的pom.xml文件,我给了Selenium依赖项.
  1. It is portion the code after driver=new ChromeDriver(); line it give me error i check with sysout, errors are in the 2, well i am not well experienced using Maven but i am checking my pom.xml file , i gave Selenium dependencies.

-有什么建议吗?有任何帮助吗?

-Any advice?, any helps appreciated

public WebDriver initilizeDriver() throws IOException
{
    Properties prop= new Properties();
    FileInputStream fıs=new FileInputStream("C:\\Users\\Melih Sancak\\my-amazonTest\\src\\main\\java\\com\\ObjectRepisotary\\app\\data.properties");
    prop.load(fıs);
    String browserName =prop.getProperty("browser");
    System.out.println(browserName);
    if(browserName.equals("chrome"))
    {
        System.setProperty("webdriver.chrome.driver", "C:\\Users\\Melih Sancak\\Downloads\\chromedriver.exe");
        driver=new ChromeDriver();
    }
}

2.错误:

java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableMap
    at org.openqa.selenium.remote.service.DriverService$Builder.<init>(DriverService.java:253)
    at org.openqa.selenium.chrome.ChromeDriverService$Builder.<init>(ChromeDriverService.java:94)
    at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:88)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:123)

推荐答案

文件com/google/common/collect/ImmutableMap可能已损坏:

部署Maven项目会抛出Java .util.zip.ZipException:无效的LOC标头(错误的签名)

如果您使用的是eclipse,并且要检查此文件是否已损坏,请尝试将其打开.它位于番石榴Maven依赖项中.如果它已损坏,则会显示invalid LOC header (bad signature).

If you are using eclipse and want to check whether this file is corrupted just try to open it. It is located in the guava maven dependency. If it is corrupted it will show you invalid LOC header (bad signature).

然后找到.m2文件夹,搜索损坏的文件并将其删除.最后运行一个Maven更新.

Then locate the locate the .m2 folder, search for the corrupted file and delete it. Finally run a maven update.

那为我解决了这个问题.

That solved the problem for me.

这篇关于java.lang.NoClassDefFoundError:com/google/common/collect/ImmutableMap,同时在Java Selenium中将WebDriver与Maven依赖项一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆