为什么我的春季背景刷新事件被调用两次?
2022-09-01 23:16:51
我有一个注册了Spring ApplicationListener bean来侦听 ContextRefreshed 事件。但是,由于一些奇怪的原因,我在上下文初始化完成时获得了对该方法的两次调用。这是正常行为还是表明我的配置存在问题?我正在使用Jetty 8作为我的Servlet容器。onApplicationEvent(ContextRefreshedEvent)
我的相关网页.xml配置如下
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/config/spring/spring-config.xml</param-value>
</context-param>
<servlet>
<servlet-name>Spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value></param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet-mapping>
<servlet-name>Spring</servlet-name>
<url-pattern>/service/*</url-pattern>
</servlet-mapping>
谢谢!