等待性-java.lang.NoClassDefFoundError在尝试从eclipse运行程序时抛出

等待性-java.lang.NoClassDefFoundError在尝试从eclipse运行程序时抛出,java,awaitility,Java,Awaitility,等待性用于同步异步操作。因此,我尝试在我的自动化项目中使用它来处理同步问题。所以我尝试了一些基本的程序 import static org.awaitility.Awaitility.*; import static org.awaitility.Duration.*; import static java.util.concurrent.TimeUnit.*; import static org.hamcrest.Matchers.*; import java.util.concurrent.

等待性用于同步异步操作。因此,我尝试在我的自动化项目中使用它来处理同步问题。所以我尝试了一些基本的程序

import static org.awaitility.Awaitility.*;
import static org.awaitility.Duration.*;
import static java.util.concurrent.TimeUnit.*;
import static org.hamcrest.Matchers.*;
import java.util.concurrent.TimeUnit;

 public static void main( String[] args )
        {        
            System.setProperty("webdriver.chrome.driver", "C:/Learning/synchronization/Resources/chromedriver.exe");    
            WebDriver driver = new ChromeDriver();
            driver.manage().window().maximize();
            driver.get("http://www.seleniumeasy.com/test/dynamic-data-loading-demo.html");
            WebElement newUserBtn = driver.findElement(By.id("save"));
         WebElement loadingElement = driver.findElement(By.id("loading"));

            // Get a new User
            newUserBtn.click();

            await().atMost(15,TimeUnit.SECONDS).until(loadingElement::getText, not("Loading..."));
            System.out.println("User profile retrieved");
        }
但每当它遇到下面的行时,就会抛出下面的异常

await().atMost(15,TimeUnit.SECONDS).until(loadingElement::getText, not("Loading..."));
错误消息:

Exception in thread "main" java.lang.NoClassDefFoundError: org/awaitility/Awaitility
    at com.testing.automation.synchronization.App.main(App.java:35)
Caused by: java.lang.ClassNotFoundException: org.awaitility.Awaitility
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 1 more
我考虑是否遗漏了任何依赖项,从而导致以下错误。但我不确定。我正在使用maven项目的Java8版本。


等待性

我真的不知道为什么会出现这个错误

有谁能帮我解决这个问题吗?

在maven pom中,您只在
测试范围内导入该实用程序。但是,您似乎试图通过使用
main
以正常模式而不是测试模式运行应用程序

尝试从pom文件中删除前两个依赖项的
test


顺便说一句,我读了一些书,看起来这个实用程序只是为测试而设计的,而不是为生产而设计的。

在maven pom中,您只在
测试范围内导入实用程序。但是,您似乎试图通过使用
main
以正常模式而不是测试模式运行应用程序

尝试从pom文件中删除前两个依赖项的
test


顺便说一下,我读了一些书,看起来这个实用程序只是为测试而设计的,不是为生产而设计的。

谢谢@admdev-我从依赖项中删除了测试。现在它工作得很好:)谢谢@admdev-我从依赖项中删除了测试。现在它运行良好:)
<dependencies>
        <!-- https://mvnrepository.com/artifact/org.awaitility/awaitility -->
        <!-- https://mvnrepository.com/artifact/org.awaitility/awaitility -->
        <dependency>
            <groupId>org.awaitility</groupId>
            <artifactId>awaitility</artifactId>
            <version>3.1.2</version>
            <scope>test</scope>
        </dependency>


        <!-- https://mvnrepository.com/artifact/org.awaitility/awaitility-proxy -->
        <dependency>
            <groupId>org.awaitility</groupId>
            <artifactId>awaitility-proxy</artifactId>
            <version>3.1.2</version>
            <scope>test</scope>
        </dependency>


        <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.4.0</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>