Run an Application
This page describes how to run a project with Eclipse.
Run 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
in the menu. -
Press Ctrl+F11.
-
Select the
Application.java
in the Project Explorer, right-click, and select .
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’ll 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.
Run 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:
-
Right-click the project in the Project Explorer view.
-
Select
. -
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.
-
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.
-
You can now open the web application in a browser at localhost:8080.
-
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.
Live Reload should be enabled by default, making the page refresh automatically.
-
To stop the server, click the Terminate icon in the Console view:
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:
Build 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 in your local Maven repository, right-click the project and select
: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:
-
The key concepts in Maven, see Learning Maven Concepts.
E0D2D6E1-71C4-42CD-B185-C692F9CCD606