相关疑难解决方法(0)

如何使用 mongoDB Java 驱动程序 3.4+ 或 3.6+ 避免异常提前到达流末尾?(插入期间)

我正在尝试使用以下代码片段将一些文档插入到上限集合中:

            // 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)

java mongodb

8
推荐指数
1
解决办法
2万
查看次数

线程“主”中的异常java.lang.NoClassDefFoundError:org / openqa / selenium / WebDriver

我在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。

java selenium maven selenium-webdriver

5
推荐指数
3
解决办法
1万
查看次数

标签 统计

java ×2

maven ×1

mongodb ×1

selenium ×1

selenium-webdriver ×1