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注解。

不经一番彻骨寒,哪有梅花扑鼻香?
原文地址:https://www.cnblogs.com/zongyao/p/13831160.html