简体   繁体   中英

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. What you're probably looking for is the regular Spring AOP support using @Aspect .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM