ssm框架问题1:@RunWith(SpringJUnit4ClassRunner.class)没有可用的导入包


I have a JUnit 4 test class in Eclipse Ganymede that has the following annotations :

I have a JUnit 4 test class in Eclipse Ganymede that has the following annotations :

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:/applicationContext.xml"})
public class TestSybaseDao extends TestCase {

This annotation gives compilation error "Type mismatch: cannot convert from Class<SpringJUnit4ClassRunner> to Class<? extends Runner>

 

在写单元测试的时候,明明包导进去了但是鼠标放到调用类还会出现这个错误。

 

出现这种情况一般有2个原因:

1.可能刚加进去的包为加载到,需要到重构配置窗口中重新加载下所有包,一般eclipse自带的是junit4.4版本的。

2.第二种原因是spring不支持junit4.5一下的版本。所以只需要把junit4.4或者更低版本升级到更高就ok了。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM