问题描述
使用springframework框架整合mybatis后在测试类中发现无法注入service,报npe
环境:
idea
spring + springmvc + mybatis
maven
所作努力
看网上大部分说测试类头顶缺失@RunWith(SpringJUnit4ClassRunner.class)
和@ContextConfiguration(locations = {"classpath:application.xml"})
两大注解,遂加之,报找不到测试类
警告: Runner org.junit.internal.runners.ErrorReportingRunner (used on class MyTest) does not support filtering and will therefore be run completely.
org.junit.runners.model.InvalidTestClassError: Invalid test class 'MyTest':
1. No runnable methods
网上解决方案大多都是如博客https://blog.csdn.net/qq_43012792/article/details/107775607,无法解决
https://weibgg.blog.csdn.net/article/details/103112618,无法解决
完整代码下载
链接: https://caiyun.139.com/m/i?0d5Crf9pDyyQY 提取码:T43K
现在还玩spingmvc,不尝试springboot?如果是springboot请看这个:springboot @Test