我正在使用ApplicationEventPublisher从Spring MVC组件(例如,服务,控制器等)发布事件。现在,我尝试使用WebApplicationContextUtils在我的Filter(javax.servlet.Filter)实现中访问ApplicationEventPublisher,但它说没有这样的ApplicationEventPublisher类型的bean。
ApplicationEventPublisher applicationEventPublisher = WebApplicationContextUtils.getWebApplicationContext(request.getServletContext()).getBean(ApplicationEventPublisher.class)
org.springframework.beans.factory.NoSuchBeanDefinitionException: No such bean of type org.springframework.context.ApplicationEventPublisher