Running an Application

Running a Spring Boot Project

If you are developing a Spring Boot project, like 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 (“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 frontend dependencies and builds a JavaScript bundle. This can take several minutes, depending on your computer and internet speed.

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

Show code

Expand code

  1. Tomcat started on port(s): 8080 (http) with context path ''
  2. 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 is run in a separate process. Therefore you are unable to 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 StackEmbedded ServerGoal 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

    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 will be compiled and the server will redeploy the application, so you should see the modified behaviour 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

    Terminate

Once the run configuration is created, you can deploy and run the web application by clicking the Run (or Debug) icon in the toolbar and selecting the corresponding run or debug configuration:

Toolbar

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

Maven Install

After starting the command, you will see how Eclipse executes the install goal build phase and all the previous phases in the 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: