美文网首页
springboot异常处理总结 2018-

springboot异常处理总结 2018-

作者: zhanghanga | 来源:发表于2018-07-08 11:52 被阅读0次

1,springBoot 处理异常有2种常见方式:

        (1) controller 层 都 继承(extends) BaseController;

        (2)定义一个全局的拦截器 xxxController,使用注解@ControllerAdvice;

2,两种方式对比:

      (1)每一个Controller 都继承 BaseController 耦合度比较高(不推荐)

      (2)@ControllerAdvice 注解新建一个统一异常处理方式,有APO面向切面的思想,个人觉得不错(推荐)  

相关文章

网友评论

      本文标题:springboot异常处理总结 2018-

      本文链接:https://www.haomeiwen.com/subject/phcouftx.html