[英]Will I have any collisions coming from the @ControllerAdvice if I use it to populate a @ModelAttribute
[英]Is there any way to use @ControllerAdvice on @Service
我有一個項目需求,我將沒有任何@Controller
或@RestController
但是我需要為我的服務層提供一個全局異常處理程序,因此我需要在@Service
上配置@ControllerAdvice
,請告訴我是否有其他方法也可以做到這一點。
@ControllerAdvice
與Spring MVC控制器特別相關,因此您不能在任意bean上使用它。 您可能正在尋找的是使用@Aspect
的常規Spring AOP支持。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.