Get your application up and running

Adding the route to the main view

We previously replaced the original MainView with our own. The new one does not have an @Route annotation which we need set our view as the the root route.

  1. Switch back to IntelliJ IDEA.

  2. Expand the src/main/java/com.vaadin.tutorial.crm.ui package and open MainView.java.

  3. Add the @Route("") annotation at the beginning of the MainView class.

Your MainView class should now look like this:

@Tag("main-view")
@JsModule("./src/views/main-view.js")
@Route("") (1)
public class MainView extends PolymerTemplate<MainView.MainViewModel> {
    // The rest of the file is omitted from the code snippet
}
  1. The @Route annotation maps http://localhost:8080/ to MainView.

Running the project

Next, we run the project to see how the new layout will look like.

The easiest way to run the project for the first time is to:

  1. Open the Application Java class in src/main/java/com/vaadin/tutorial/crm/Application.java

  2. Click the green play button next to the line which starts with "public class Application".

    This starts the application and automatically adds a run configuration for it in IntelliJ IDEA. Later, when you want to run or restart the application, you can build, run/restart, stop and debug the application from the toolbar:

When the build is finished and the application is running. Open http://localhost:8080/ in your browser to see the result.

Proceed to the next chapter to connect your views to Java: Connecting your Main View to Java