Vaadin flow - Having views in a different package

Viewed 139

Exists in vaadin flow an option to have the views in a different package and not as a subpackage where the main spring boot class is located? e.g.

com.xyz.vaadin.app --> Spring Boot Main
com.xyz.vaadin.config
com.xyz.vaadin.views  --> Main view

I already tried to use "@SpringBootApplication scanBasePackages" or "scanBasePackageClasses" and passed the main view package or main view class but after starting the application it does not found the view. Error "Route is not found"

2 Answers

You can add the @EnableVaadin annotation on your Spring application class, and supply the package name. So in your example it would be

@SpringBootApplication
@EnableVaadin(value = "com.xyz.vaadin.views")
public class MainClass {

    public static void main(String[] args) {
        SpringApplication.run(MainClass.class, args);
    }
}

This issue can be triggered when you instantiate "RouterLink" with views/component that aren't annotated with "@Route". It happens even if you actually don't try to access to this particular view.

Related