java 接口报错之@Autowired

1,100 阅读1分钟

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause

查看service在当前controller是否被注入如我的页面,则

因为在上面   private IUserService iUserService;的时候没有添加 @Autowired

正确应用为

@Autowired
private IUserService iUserService;