Servlet.service() for servlet [dispatcherServlet] in context with path [] 报错解决方法

SpringBoot项目启动成功,访问API时报错。页面显示

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.

控制台报错:Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request 

原因:
Service层实现类未添加注解@Autowired。
@Autowired的作用是自动注入依赖的Bean。

修改方法:

加上@Autowired注解。

posted @ 2019-10-06 11:48  9529  阅读(41511)  评论(0编辑  收藏  举报