这个是测试单元的代码,我直接调用mapper接口,但是爆出空指针
applicationcontxt.xml中的mapper.xml文件的路径再mybatis的文件中,请哪位大神给个答案,谢谢
需要在这个测试类上加上 spring 的路径的哦:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:spring/*.xml"})
在 TestController类上方加上这几行,locations 是你的项目的 Spring 配置文件路径,换一下就可以了哦。
否则注入时不知道具体的 Bean 的配置信息哦。