From SpringBootServletInitializer javadoc: A handy, self-confident WebApplicationInitializer for applications that have only one Spring servlet and at most one filter (which by itself is enabled only when Spring Security is detected). If your application is more complex, consider using one of the other WebApplicationInitializers
So, if you want to create a war and want to turn on the session listener, you must use the WebApplicationInitializer directly. Here is an example from javadoc:
public class MyWebAppInitializer implements WebApplicationInitializer { @Override public void onStartup(ServletContext container) {
Since you have full control over the ServletContext, before it is fully initialized, it's easy to add your listener:
container.addListener(YourListener.class);
Serge Ballesta
source share