[英]Is there any way to use @ControllerAdvice on @Service
我有一个项目需求,我将没有任何@Controller
或@RestController
但是我需要为我的服务层提供一个全局异常处理程序,因此我需要在@Service
上配置@ControllerAdvice
,请告诉我是否有其他方法也可以做到这一点。
@ControllerAdvice
is specifically relevant to Spring MVC controllers, so you can't use it on arbitrary beans. @ControllerAdvice
与Spring MVC控制器特别相关,因此您不能在任意bean上使用它。 What you're probably looking for is the regular Spring AOP support using @Aspect
. 您可能正在寻找的是使用
@Aspect
的常规Spring AOP支持。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.