Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception 很详细!!!
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is com.suntang.common.exception.RRException: 用户账号已被占用] with root
![](https://csdnimg.cn/release/devpress/public/img/ic-book.4f347164.png)
控制台报错信息
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is com.suntang.common.exception.RRException: 用户账号已被占用] with root cause
首先验证一下三种情况是否都满足:
1.controller层没有加@ResponseBody
2.Service层实现类未添加注解@Autowired
3.@RestController使用成了@Controller
我这里已经验证过以上三种情况了,都无法解决问题
问题分析:postman报错
首先手动抛出的自定义异常没有没被全局异常处理到,然后一步一步debug调试看报错
出现一个新的异常:java.lang.reflect.InvocationTargetException
查了一下这个异常报错原因,大概就是:InvocationTargetException异常由Method.invoke(obj, args...)方法抛出。当被调用的方法的内部抛出了异常而没有被捕获时,将由此异常接收。
然后分析一下:我是做了全局异常切面处理的,但是并没有走到全局异常处理切面类那里去,那就极有可能是启动是没有扫描到全局异常处理切面类了,
我这里切面类是在common包下面的的,启动类没有配置扫描common包,所以就扫描不到,导致报错了
解决办法:启动类配置包扫描使能够扫描到common包下的bean即可。
@SpringBootApplication(scanBasePackages = {"com.suntang.common","com.suntang.login"})
今天的不开心就止于此吧!明天依旧光芒万丈鸭!!!!^_^
更多推荐
所有评论(0)