我有一个项目需求,我将没有任何@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.