解决报错:
java.lang.NullPointerException: Cannot invoke "com.example.forum.dao.UserMapper.selectByPrimaryKey(java.lang.Long)" because "this.userMapper" is null
在写代码测试的时候,报了如上错误。
原因:一般是因为注解没有加上的原因。例如@Test,@Autowired,@SpringBootTest
仔细检查加上注解即可。
解决报错:
java.lang.NullPointerException: Cannot invoke "com.example.forum.dao.UserMapper.selectByPrimaryKey(java.lang.Long)" because "this.userMapper" is null
在写代码测试的时候,报了如上错误。
原因:一般是因为注解没有加上的原因。例如@Test,@Autowired,@SpringBootTest
仔细检查加上注解即可。