Documentation versions (currently viewingVaadin 24)

Spring Boot Applications with MPR & Flow

This step is needed if your Vaadin 7 or 8 application uses Spring Boot. If it doesn’t, go back to the framework selection.

Updating Spring Version

Update parent org.springframework.boot:spring-boot-starter-parent to 3.0.0 or newer.

The dependency com.vaadin:vaadin-spring-boot-starter shouldn’t have a version defined since it comes from vaadin-bom.



See the Using Vaadin with Spring Boot tutorial for more on how Flow integrates with Spring.

Handling SpringUI

The @SpringUI, as shown in the UI example below, can be replaced with a @Route:

public class TodoUI extends UI {
    protected void init(VaadinRequest vaadinRequest) {
        setContent(new HorizontalLayout());

You can change the example above to look like the following:

public class TodoUI extends Div implements HasLegacyComponents {
    private void buildLayouts() {
        add(new HorizontalLayout());

Annotations in the UI, such as @Theme and @Title, are dealt with later in the tutorial. Most of them have similar counterparts in either Flow or MPR.

Update Imports

Any com.vaadin.spring.annotation imports needs to be changed to com.vaadin.flow.spring.annotation.

The V14 Spring add-on doesn’t have a feature comparable with ViewScope.

Handling SpringView

Any @SpringView should be updated to a Flow Route by wrapping it as a MprRouteAdapter<? extends View> or re-writing it to be a Flow Component. See Upgrading Views to Flow Routes for details.

The easiest way to migrate a Spring view is to wrap it in a component that extends MprRouteAdapter<? extends View> and then define a navigation target for it with @Route. No other annotation for the wrapper component or the wrapped view is needed.

Starting with Vaadin 21, @RouteScope without @RouteScopeOwner annotation can be used as a replacement for @ViewScope. The bean within @RouteScope — without specified @RouteScopeOwner — stays preserved until the current navigation target/view is active (attached). It’s possible to use @RouteScopeOwner explicitly, but that requires an extra line.

The following is an example of using @RouteScope:

public class HelpRoute extends MprRouteAdapter<HelpView>  {

public class HelpView extends VerticalLayout implements View {

    private ApplicationContext context;

    public void enter(ViewChangeEvent event) {
       HelpService service = context.getBean(HelpService.class);
       // every time when {@code context.getBean(HelpService.class)} called
       // the HelpService instance is the same until we're inside HelpView/HelpRoute
       Label label = new Label(service.getHelp());

public class HelpService {

    public String getHelp(){
        return "some help";


When porting the UI to a flow component, you lose the ability to use UI methods, such as setErrorHandler. You can still access those methods by using UI.getCurrent(). The method setContent isn’t supported, though. You should use instead the add method from your Flow layout.

When running MPR with Spring, the Spring integration is done with Flow — no longer with Vaadin 7 or 8. Therefore, sometimes you need to import classes from the old vaadin-spring project to make your MPR project to compile, since those classes aren’t present anymore in the new versions of vaadin-spring.

The source code of vaadin-spring can be found on GitHub. Below are examples of such classes:

  • com.vaadin.spring.access.SecuredViewAccessControl;

  • com.vaadin.spring.access.ViewAccessControl;

  • com.vaadin.spring.internal.SpringBeanUtil;

  • com.vaadin.spring.internal.VaadinSpringComponentFactory;

  • com.vaadin.spring.server.SpringVaadinServletService;

If your routes are defined in a different package than the Spring application itself, you need to annotate your application with @EnableVaadin, for Spring to be able to scan the appropriate folders for beans. Below is an example of this:

// Assuming that Application is in a different package than the classes
// annotated with @Route
public class Application extends SpringBootServletInitializer {

The next step is Configuring UI Parameters.