[英]SpringJUnit4ClassRunner isn't recognized as a type
My aplication uses Spring 4.3.1 and JUnit 4.12. 我的应用程序使用Spring 4.3.1和JUnit 4.12。
I have been trying test my methods with JUnit test cases. 我一直在尝试用JUnit测试用例测试我的方法。
I placed the @RunWith(SpringJUnit4ClassRunner.class) annotation in my test class, but eclipse complains "Class cannot be resolved to a type". 我在测试类中放置了@RunWith(SpringJUnit4ClassRunner.class)批注,但是eclipse抱怨“类无法解析为类型”。
I read that this was enough for Eclipse to recognize SpringJUnit4ClassRunner, but isn't. 我读到,这足以让Eclipse识别SpringJUnit4ClassRunner,但事实并非如此。
Is there Anything else remaining to do? 还有什么要做的吗?
Try to: 尝试:
Adding the dependency spring-test the problem has been solved. 添加依赖性弹簧测试,此问题已解决。
I didn't know there was need for this additional dependence, but someone told me here. 我不知道是否需要这种额外的依赖,但是有人在这里告诉我。 Thank you.
谢谢。
I initially said that this measure was not enough because I had written the dependency version name wrongly and Maven was not finding the resource. 最初,我说这种措施是不够的,因为我错误地输入了依赖版本名称,并且Maven找不到资源。 But now it works!
但是现在可以了!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.