看网上视频跟着学的SpringMVC,不知道是哪里出错了?
applicationContext.xml文件扫描:
<context:component-scan base-package="com.atguigu">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
Mapper测试类,两个注入都是null:
@ExtendWith(SpringExtension.class)//spring junit5
@ContextConfiguration(locations = {"classpath:applicationContext.xml"})
public class MapperTest {
@Autowired
DepartmentMapper departmentMapper;
@Autowired
EmployeeMapper employeeMapper;
文件结构:
DepartmentMapper和EmployeeMapper接口上添加注解或者不添加注解都一样的结果,请问是哪里出错了?
错误信息:
null
java.lang.NullPointerException: Cannot invoke "com.atguigu.crud.dao.EmployeeMapper.insertSelective(com.atguigu.crud.bean.Employee)" because "this.employeeMapper" is null
at com.atguigu.crud.test.MapperTest.testCRUD(MapperTest.java:45)