简体   繁体   English

尝试在不使用Maven的情况下在Eclipse中设置一个黄瓜项目

[英]Trying to setup a cucumber-project in eclipse without using Maven

I am new to cucumber, I am trying to configure a Java-project without using Maven, I am having the following exception. 我是黄瓜新手,我尝试在不使用Maven的情况下配置Java项目,但遇到以下异常。 I think there is an issue with the path of a .feature file 我认为.feature文件的路径存在问题

Exception: 例外:

java.lang.NoClassDefFoundError: cucumber/io/ResourceLoader
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2398)
at java.lang.Class.getConstructor0(Class.java:2708)
at java.lang.Class.getConstructor(Class.java:1659)
at cucumber.runtime.Utils.hasConstructor(Utils.java:30)
at cucumber.runtime.io.ClasspathResourceLoader.instantiateSubclasses(ClasspathResourceLoader.java:55)
at cucumber.runtime.Runtime.loadBackends(Runtime.java:81)
at cucumber.runtime.Runtime.<init>(Runtime.java:61)
at cucumber.api.junit.Cucumber.<init>(Cucumber.java:59)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:31)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:24)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:33)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:48)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassNotFoundException: cucumber.io.ResourceLoader
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 27 more

I have also attached the image of my project setup. 我还附加了我的项目设置的图像。

在此处输入图片说明

Any help will be awesome. 任何帮助都会很棒。

Thanks! 谢谢!

java.lang.NoClassDefFoundError: cucumber/io/ResourceLoader

this exception means that the class cucumber.io.ResourceLoader is not found in the classpath of your Project. 此异常意味着在您的项目的类路径中找不到类Cucumber.io.ResourceLoader。 Try to add the cucumber-core.jar to the classpath of your project following this eclipse documentation . 遵循此eclipse文档,尝试将Cucumber-core.jar添加到项目的类路径中。

It would help if you could let us know what libraries you referenced in your project. 如果您可以让我们知道您在项目中引用了哪些库,这将有所帮助。 cucumber-core is referenced by cucumber-java . cucumber-corecucumber-java引用。 So if you have cucumber-java , you don't need to have cucumber-core in your class path. 因此,如果您有cucumber-java ,则无需在类路径中使用cucumber-core Looking at your code, I notice you use @Cucumber.Options . 查看您的代码,我注意到您使用@Cucumber.Options This is deprecated in the latest release, so looks like you are not using latest release. 最新版本不推荐使用此功能,因此您似乎未使用最新版本。 Try using cucumber 1.1.5 jars . 尝试使用cucumber 1.1.5 jars

Also any reason why aren't you using maven? 还有什么原因为什么不使用Maven? Maven is supposed to make these things easier. Maven应该使这些事情变得容易。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM