Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception

idea报错

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): org.example.sys.mapper.UserMapper.getRoleNameByUserId] with root cause

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): org.example.sys.mapper.UserMapper.getRoleNameByUserId at org.apache.ibatis.binding.MapperMethod$SqlCommand.(MapperMethod.java:235) ~[mybatis-3.5.6.jar:3.5.6] at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.(MybatisMapperMethod.java:51) ~[mybatis-plus-core-3.4.2.jar:3.4.2] at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.lambda$cachedInvoker$0(MybatisMapperProxy.java:111) ~[mybatis-plus-core-3.4.2.jar:3.4.2]

......

postman报错

postman用get方法对我的接口进行测试,一直报错500.


HTTP 状态码 500 表示 "Internal Server Error",它是服务器端发生了意外错误或异常,导致服务器无法正常处理请求并返回正确的响应。

当服务器在处理请求时发生了未预料的错误,或者代码中存在 bug、配置问题等,可能会导致服务器出现内部错误,从而返回 500 错误。

这个问题一般是后端代码存在 bug、逻辑错误或异常,导致无法正常执行请求以及数据库没有正常连接导致的。

解决方案1(注解原因)


1.controller层没有加@ResponseBody

2.Service层实现类未添加注解@Autowired

3.@RestController使用成了@Controller

解决方法2(文件问题)

我写了一个getRoleNameByUserId方法,他的操作有需要将数据库中的两个表进行关联,于是我还写了xml文件,

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception_第1张图片

XML 文件通常被用来存放 SQL 映射语句,用于将 Java 对象与数据库表之间的操作进行映射。而我的问题就在这里,我的xml文件被我放在了mappersys里,导致他方法调用 SQL 映射语句的时候没有找到xml文件,从而导致了报错。

你可能感兴趣的:(servlet,java)