SpringBoot项目中关于Controller层调用Service层踩过的坑
#SpringBoot项目中关于Controller层调用Service层踩过的坑
刚开始学SpringBoot项目时,使用Controller层调用Service层声明变量时,一开始是这样写的
下面展示一些 内联代码片
。
@Autowired
private static IHomeWorkService homeWorkServiceService;
但是一直会报空指针异常,去看了看service层和mapper层写的sql都是没有问题的。
最后才发现原来是 多写了一个 static 修饰导致的,太低级的错误。
@Autowired
private IHomeWorkService homeWorkServiceService;