2

I'm trying to reproduce a simplified version of the official Vaadin Dashboard Demo, but I'm using Spring Boot for managing dependencies.

In DashboardServlet.java file you will find this code:

public class DashboardServlet extends VaadinServlet {
    @Override
    protected final void servletInitialized() throws ServletException {
        super.servletInitialized();
        getService().addSessionInitListener(new DashboardSessionInitListener());
    }
}

The demo is using a customized servlet.

Question: how can this be achieved in Spring Boot? How can I make Spring Boot inject my custom servlet class?

Pavel Bastov
  • 6,911
  • 7
  • 39
  • 48

1 Answers1

5

You must create a manage bean which name is vaadinServlet, and you want to extend the SpringVaadinServlet class. This should work:

@Component("vaadinServlet")
public class MySpringVaadinServlet extends SpringVaadinServlet {

    @Override
    protected void servletInitialized() throws ServletException {
        super.servletInitialized();
    }
}
Henri Kerola
  • 4,947
  • 1
  • 17
  • 19
  • What if you need to override some parameters? Using `@Bean public ServletRegistrationBean vaadinServlet()` in an `@Configuration` class doesn't seem to work. – herman Apr 21 '16 at 10:56