SpringMVC @autowrid注入空指针

倚然君

关注

阅读 73

2022-07-12


今天突然遇到空指针的问题

SpringMVC 项目出现了@Autowrid突然出现了空指针的问题

    @Autowired
    private IGfGoodsInfoChose choseService;

查看了网上的各种说法

包括实现类上@Service的注释,没有问题

严重: Servlet.service() for servlet [springMVC] in context with path [/wzshop] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause
java.lang.NullPointerException
at com.wdg.controller.GoodsChoseController.addChoseInfo(GoodsChoseController.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.__invoke(DelegatingMethodAccessorImpl.java:43)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:45009)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:45012)
at java.lang.reflect.Method.invoke(Method.java:497)

 排查了很久,原来是我自己的方法的问题

我的方式是private方法

SpringMVC @autowrid注入空指针_mvc

我这边修改成为public 就没有问题了

希望对你有所帮助

 

 

 

精彩评论(0)

0 0 举报