我正在尝试使用以下代码片段将一些文档插入到上限集合中:
// get document with specific fields
Document found = collection.find().first();
String getTitle = (String) found.get("title");
String getUrl = (String) found.get("url");
String getImg = (String) found.get("img");
String getPrice = (String) found.get("price");
// document which I want to get as new
Document doc = collection.find(new Document("title", getTitle)
.append("url", getUrl)
.append("img", getImg)
.append("price", getPrice)
.append("sent", true)).first();
// if the document doesn't exist, then insert as new
if (doc == null) {
collection.insertOne(new Document("title", getTitle)
.append("url", getUrl)
.append("img", getImg)
.append("price", getPrice)
.append("sent", true)); …Run Code Online (Sandbox Code Playgroud) 我在pom.xml中添加了最新的Selenium依赖项
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.7.1</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我使用pom.xml在目录内运行了mvn clean install,并且根据Selenium文档,我还在应用程序类中导入了正确的类。
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试运行主方法时,出现以下错误
Exception in thread "main" java.lang.NoClassDefFoundError:
org/openqa/selenium/WebDriver
Run Code Online (Sandbox Code Playgroud)
我查看我的〜/ .m2 / repository文件夹,但没有看到openqa文件夹,但看到了seleniumhq文件夹。
为什么maven不安装openqa文件夹,为什么文档说要从org.openqa导入...当我的jar存储库中不存在该文件时。我很困惑,我只想在本地存储库中成功导入Selenium Webdriver。