測試類中出現的異常


 

1.Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.lhh.myspringboot.service.AdminService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

 

原因:少注解@Service

 

2. Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'adminServiceImpl': Unsatisfied dependency expressed through field 'adminDao'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.lhh.myspringboot.dao.AdminDao' available: expected at least 1 bean which qualifies as autowire candidate. 

 

解決:

 

3.org.junit.runners.model.InvalidTestClassError: Invalid test class 'com.lhh.myspringboot.MySpringbootApplicationTests':

1. Method adminTest() should be public
2. Method contextLoads() should be public

解決:  測試類方法應當是public

 

4.org.junit.runners.model.InvalidTestClassError: Invalid test class 'com.lhh.myspringboot.MySpringbootApplicationTests':

1. No runnable methods

解決: junit導包有誤,應該導 org.junit.Test

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM