java - 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一起使用,而是在寻找可以在我的服务层中使用的东西。
解决方案
推荐阅读
- amazon-web-services - AWS SSL 证书导出
- python - 如何在 Python 中执行以下 EXCEL 函数(如果函数在 if 函数中)
- html - 无法将 mp3 文件上传到 cloudinary
- swift - 如何在 SwiftUI 的 Widget 中使用 LinkPresentation 框架来显示 urlImage 预览?
- javascript - 有没有办法显示整个 div 的内容,只有当两个(两个)复选框被点击时,使用 jquery/js 或只是 html?
- java - java.lang.Error:SingleThreadExecutor 上超过了最大允许计数
- python - Python plot_date:如何在图形轴上格式化时间和日期
- javascript - Computed function return null - problem with fetch?
- python - c++和python之间的共享内存
- python - 如何连接具有相同键的 2 个字典,同时保留所有值?