如何解决Maven的Junit测试中的RegistryBuilder问题?

时间:2016-10-04 15:42:41

标签: java eclipse maven selenium junit

我已经在Juni中创建了一个测试并在我正在构建项目时添加到Maven项目中,并且出现错误

  

java.lang.NoClassDefFoundError:org / apache / http / config / RegistryBuilder     在   org.openqa.selenium.remote.internal.HttpClientFactory.getClientConnectionManager(HttpClientFactory.java:69)     在   org.openqa.selenium.remote.internal.HttpClientFactory。(HttpClientFactory.java:57)     在   org.openqa.selenium.remote.internal.HttpClientFactory。(HttpClientFactory.java:60)     在   org.openqa.selenium.remote.internal.ApacheHttpClient $ Factory.getDefaultHttpClientFactory(ApacheHttpClient.java:250)     在   org.openqa.selenium.remote.internal.ApacheHttpClient $厂(ApacheHttpClient.java:227)     在   org.openqa.selenium.remote.HttpCommandExecutor.getDefaultClientFactory(HttpCommandExecutor.java:96)     在   org.openqa.selenium.remote.HttpCommandExecutor。(HttpCommandExecutor.java:70)     在   org.openqa.selenium.remote.service.DriverCommandExecutor。(DriverCommandExecutor.java:62)     在   org.openqa.selenium.chrome.ChromeDriverCommandExecutor。(ChromeDriverCommandExecutor.java:40)     在   org.openqa.selenium.chrome.ChromeDriver。(ChromeDriver.java:170)     在   org.openqa.selenium.chrome.ChromeDriver。(ChromeDriver.java:159)     在   org.openqa.selenium.chrome.ChromeDriver。(ChromeDriver.java:116)     在   com.sap.drools.controller.Resource.openCheckoutPage(Resource.java:18)     在   com.sap.drools.controller.TestExpressMode.ExpressModeFileUploadTest(TestExpressMode.java:11)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at   sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)     在   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     在java.lang.reflect.Method.invoke(Method.java:498)at   org.junit.runners.model.FrameworkMethod $ 1.runReflectiveCall(FrameworkMethod.java:44)     在   org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)     在   org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)     在   org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)     在   org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)     在   org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)     在org.junit.runners.ParentRunner $ 3.run(ParentRunner.java:193)at   org.junit.runners.ParentRunner $ 1.schedule(ParentRunner.java:52)at at   org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)at at   org.junit.runners.ParentRunner.access $ 000(ParentRunner.java:42)at at   org.junit.runners.ParentRunner $ 2.evaluate(ParentRunner.java:184)at at   org.junit.runners.ParentRunner.run(ParentRunner.java:236)at at   org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)     在   org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)     在   org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)     在   org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)     在   org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)     在   org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)   引起:java.lang.ClassNotFoundException:   org.apache.http.config.RegistryBuilder 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 at   java.lang.ClassLoader.loadClass(ClassLoader.java:357)... 36更多

如何解决这个问题并顺利在Maven项目中执行junit测试?

由于

1 个答案:

答案 0 :(得分:0)

在pom中添加依赖

    org.apache.httpcomponents     的HttpCore     4.4     测试

  org.apache.httpcomponents   HttpClient的   4.5.2

            org.apache.httpcomponents             httpmime             4.5.2