title: How to add HttpSessionEventPublisher for logout in Spring Boot
body: <p>I am trying to implement a Spring Boot version of Pet Clinic overriding as little of Spring Boot defaults as possible.</p>
  
  <p>At this point, my logout link doesn't seem to work and I've been told that it is because I haven't properly added <code>HttpSessionEventPublisher</code> to my application.</p>
  
  <p>How can I add <code>HttpSessionEventPublisher</code> to my application?</p>
  
  <p>I've tried the following:</p>
  
  <pre><code>@Component
  @Configuration
  public class WebXmlConfig implements WebApplicationInitializer {
      @Override
      public void onStartup(ServletContext servletContext) throws ServletException {
          servletContext.addListener(new HttpSessionEventPublisher());
      }
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>@Bean
  public ServletListenerRegistrationBean&lt;HttpSessionEventPublisher&gt; getHttpSessionEventPublisher() {
      return new ServletListenerRegistrationBean&lt;HttpSessionEventPublisher&gt;(new HttpSessionEventPublisher());
  }
  </code></pre>
  
  <p>My main class does not extend any classes. If that is required for me to add <code>HttpSessionEventPublisher</code>, I would need to know which class also.</p>
  
  <p>None of the Spring Boot examples log out properly, so I have nothing to based on off of.</p>
  
  <p>Any help would be appreciated.</p>