您好我正在尝试重写我的旧代码以使用Spring Boot。 我有一个听众public class ExecutorListener implements ServletContextListener
。如何在春季开机注册ServletContextListener
如何为Spring Boot注册此侦听器? 我已经试过:
@SpringBootApplication
@ComponentScan
public class Application extends SpringBootServletInitializer {
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
super.onStartup(servletContext);
servletContext.addListener(new ExecutorListener());
}
}
但contextInitialized
方法不叫。