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?
This question is related to
java
spring
eclipse
spring-boot
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).
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>
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".
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).
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.
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
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.
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.
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
Source: Stackoverflow.com