【问题标题】:Java Gradle with Selenium webdriver error at Jar Runtime在 Jar 运行时出现带有 Selenium webdriver 错误的 Java Gradle
【发布时间】:2020-11-24 01:11:00
【问题描述】:

在一个基本的 Gradle 项目中,我发现了一个问题或错误,当我使用 implementation 而不是 compile 时,它不会在 jar 中运行。我的主类有两个导入,import org.openqa.selenium.WebDriver;import org.openqa.selenium.chrome.ChromeDriver; 但是我使用实现时似乎不喜欢它。

implementation 'org.seleniumhq.selenium:selenium-java:3.141.59'
compile 'org.seleniumhq.selenium:selenium-java:3.141.59'

当我使用implementation 时,我明白了,

Error: Unable to initialize main class Main.Main
Caused by: java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriver

但是当我使用compile 时,它可以正常工作并加载。这是我唯一改变的事情,我认为这两个陈述的意思是一样的,但对于任何有类似问题的人来说,你去吧。 (我知道 compile 已被弃用,但它可以工作)

【问题讨论】:

    标签: java selenium selenium-webdriver gradle dependencies


    【解决方案1】:

    只需尝试将implementation 替换为compile

    【讨论】:

      猜你喜欢
      • 2013-06-26
      • 2013-12-23
      • 2018-01-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多