Servlet.service() for servlet [dispatcherServlet] in context with path [] th报错

╰+哭是因爲堅強的太久メ 2023-09-28 22:46 102阅读 0赞

当我们做SpringMvc项目的时候,控制台报错信息 Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause 错误:无法请求到服务 Servlet.service() for servlet [dispatcherServlet] in context with path [] th

09d2ab6e3cfb420ab9259c8662e1c26e.png

可能出错的地方:
1.controller层没有加@ResponseBody
2.Service层实现类未添加注解@Autowired
3.@RestController使用成了@Controller
4.数据库连接:

65431fda7baf4399b2d9c2c2caa3d881.png

Servlet.service() for servlet [dispatcherServlet] in context with path [] th报错修改方法:

1、加上@Autowired注解。

2、当你检查了注解没有问题的时候,一定要先检查数据库连接,url是否写对,用户名,密码是否正确。这些常见事情往往是错误的源头。

发表评论

表情:
评论列表 (有 0 条评论,102人围观)

还没有评论,来说两句吧...

相关阅读