【发布时间】: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