Krishan Babbar
Krishan Babbar

Reputation: 798

How to run Spring Boot web application in Eclipse itself?

I am able to run few sample applications in my Eclipse (STS). Now, I want to run a web application within eclipse itself.

I tried with sample application "spring-boot-sample-web-jsp" given at the link and I am able to export its war into external tomcat and run the application. Now my question is how to run a Spring Boot Web application into eclipse itself?

Upvotes: 54

Views: 309112

Answers (11)

Sen'IT
Sen'IT

Reputation: 66

For me i wasn't seeing the option because spring tool suite was not correctly installed in my eclipse. I used this solution : Missing Spring Properties Yaml Editor and and Spring Properties Editor with Spring Tools 3.9.2

note that my eclipse wasn't able to install it because of dependence conflict i had got to unistall all spring plugin and install again

after install the option showed up

Upvotes: 0

Paulo Merson
Paulo Merson

Reputation: 14467

You can also use the "Spring Boot App" run configuration. For that you'll need to install the Spring Tool Suite plug-in for Eclipse (STS).

Upvotes: 6

Suraj
Suraj

Reputation: 11

May be useful for someone.. In Run as if you are getting only java application (No spring bootapp).. then probably you need to install "Spring Tools (aka Spring IDE and Spring Tool Suite)" through Eclipse market place. After successful installation and restart of Eclipse.. now you can see in Run as "Spring Boot app".

Upvotes: 0

Kaushal Jha
Kaushal Jha

Reputation: 91

Choose the project in eclipse - > Select run as -> Choose Java application. This displays a popup forcing you to select something, try searching your class having the main method in the search box. Once you find it, select it and hit ok. This will launch the spring boot application.

I do not have the spring tool suite installed in eclipse yet and still, it works. I hope this helps.

Upvotes: 8

Prabhakar Kumar Ojha
Prabhakar Kumar Ojha

Reputation: 59

If you are doing code in STS you just need to add the devtools dependency in your maven file. After that it will run itself whenever you will do some change.

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
</dependency>

Upvotes: 0

Darren Parker
Darren Parker

Reputation: 1812

This answer is late, but I was having the same issue. I found something that works.
In eclipse Project Explorer, right click the project name -> select "Run As" -> "Maven Build..."
In the goals, enter spring-boot:run then click Run button.

I have the STS plug-in (i.e. SpringSource Tool Suite), so on some projects I will get a "Spring Boot App" option under Run As. But, it doesn't always show up for some reason. I use the above workaround for those.
Here is a reference that explains how to run Spring boot apps:
Spring boot tutorial

Upvotes: 140

rsp
rsp

Reputation: 911

I was also trying to run Spring Boot application in Eclipse, without any plugins.

Step 1

Right click on your project. Select "Run As" -> "Maven build...". Then in "Goals" field, enter "spring-boot:run". Apply & Run.

After this you do not have to Run again.

Step 2

After making any change, clean your project. After cleaning, it automatically builds the project once. Then when you will refresh your pages on browser, change will be reflected.

Upvotes: 7

JefinOJ
JefinOJ

Reputation: 9

In my case, I had to select the "src/main/java" and select the "Run As" menu Just like this, so that "Spring Boot App" would be displayed as here.

Upvotes: 1

deepak prajapati
deepak prajapati

Reputation: 291

First Method:(if STS is available in eclipse)
1.right click on project->run as ->Spring Boot app.

Second Method:
1.right click on project->run as ->run configuration
2. set base directory of you project ie.${workspace_loc:/first}
3. set goal spring-boot:run
4. Run

Third Method:
1.Right click on @SpringBootApplication annotation class ->Run as ->Java Application

Upvotes: 10

Md. Kamruzzaman
Md. Kamruzzaman

Reputation: 1905

Steps: 1. go to Run->Run configuration -> Maven Build -> New configuration
2. set base directory of you project ie.${workspace_loc:/shc-be-war}
3. set goal spring-boot:run
4. Run project from Run->New_Configuration

enter image description here

Upvotes: 24

geoand
geoand

Reputation: 64011

Just run the main method which is in the class SampleWebJspApplication. Spring Boot will take care of all the rest (starting the embedded tomcat which will host your sample application).

Upvotes: 27

Related Questions