Documentation

Documentation versions (currently viewingVaadin 23)

You are viewing documentation for Vaadin 23. View latest documentation

Running an Application

Running a Spring Boot Project

If you are developing a Spring Boot project, such as one created with Vaadin Start, Spring Boot makes it easier to run a Java web application, because it takes care of starting and configuring the server.

To run your application, all you need to do is to run the Application class that contains the main() method that starts Spring Boot. Eclipse automatically detects that you have such a class with a main() method and lets you run it.

To start your application, you can do any of the following:

  • Click Run Application (the "play" icon) in the toolbar.

  • Select Run  Run in the menu.

  • Press Ctrl+F11.

  • Select the Application.java in the Project Explorer, right-click, and select Run As  Java Application.

The first time you start a Vaadin application, it downloads front-end dependencies and builds a JavaScript bundle. This can take several minutes, depending on your computer and internet speed.

You know that your application has started when you see the following output in the console:

Tomcat started on port(s): 8080 (http) with context path ''
Started Application in 80.189 seconds (JVM running for 83.42)

You can now open the web application in a browser at localhost:8080.

Running the Application with Maven

To run the application in an embedded web server, you need to create a run configuration, a shortcut to run a task in Eclipse, in this case a Maven goal.

Note
Debugging Spring Boot applications
When you run a Spring Boot application with Maven, it’s executed in a separate process. Therefore you can’t run it in debug mode.

You can create such a run configuration as follows:

  1. Right-click the project in the Project Explorer view.

  2. Select Run As  Maven build.

  3. In the Edit Configuration window, for Goals enter the goals to run.

    Technology Stack Embedded Server Goal to Run

    Spring Boot

    spring-boot:run

    CDI / Java EE

    Apache TomEE

    tomee:run

    Plain Java

    Jetty

    jetty:run

    Optionally, you can also give the run configuration a new name.

    spring-boot:run configuration

  4. Click Run to save the new configuration and execute it.

    You should see the Console view with the log generated by the application and the server.

  5. You can now open the web application in a browser at localhost:8080.

  6. If you modify and save any of the project Java source files, they are compiled and the server redeploys the application, so you should see the modified behavior by reloading the page.

    You can also enable Live Reload to have the page refreshed automatically.

  7. To stop the server, click the Terminate icon in the Console view:

    Terminate

When the run configuration has been created, you can deploy and run the web application. You do this by clicking the Run (or Debug) icon in the toolbar and selecting the corresponding run or debug configuration:

Toolbar

Building a Maven Goal

The Eclipse IDE has built-in integration with Maven. You can run common commands such as mvn install or mvn jetty:run without having to leave the IDE.

The project is built with Maven, and you can also run it in an embedded development server with Maven, as described later.

The most common commands are available in the Run As and Debug As folders when you right-click the project in the Project Explorer panel.

For example, to compile the project and install it your local Maven repository, right-click the project and select Run As  Maven install:

Maven Install

After invoking the command, you can see how Eclipse executes the install goal and all the previous phases in Maven’s default lifecycle. Building the application downloads dependencies from the repositories and copies the generated artifacts into your local Maven repository, among other things.

You can find additional useful options in the Maven sub-menu.

To learn more about the topics covered here:

E0D2D6E1-71C4-42CD-B185-C692F9CCD606