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