首页 > 解决方案 > Spring Boot中的异常处理方法

问题描述

是否有任何类似于Spring boot retry 的@Recover的配置,其中我可以为方法配置异常类处理程序?

例子

@ErrorHandler("error1")
String func1(String a,String b){
  // Do something which might result in an exception
}

@ErrorHandler("error1")
String func2(String a,String b){
  // Do something which might result in an exception
}

String error1(String a,String b){
  // Handle if any exception occurs
}

注意:我不是在寻找将@ControllerAdvice@ExceptionHandler一起使用,而是在寻找可以在我的服务层中使用的东西。

标签: javaspring-bootexception

解决方案


推荐阅读