Running your first Spring boot project in Eclipse IDE

gautham
Eat-Sleep-Code-Repeat
4 min readAug 26, 2020

This is the second post in the Spring boot Series

Refer the below link to create a demo spring boot project How to Create a simple Spring Boot project on Spring initializr https://start.spring.io/

In this post we will be importing the demo project we created previously into an IDE of your choice

Importing the spring boot project into Eclipse

1. Download Eclipse

You can download the eclipse from the website here https://www.eclipse.org/downloads/packages/

I will usually prefer to download the Eclipse IDE for enterprise java Developers. Depending on the Operating System and the processor type you can download for windows, linux or Mac and 32bit or 64bit from the eclipse site.

  • There is not much setup required for Eclipse, you get a .zip file when downloaded. You just have to unzip it and start using. Below is the folder structure that is inside the eclipse zip file. clicking on eclipse.exe will open up the eclipse IDE
Folder structure of eclipse after unzip
  • You can enter your workspace name and choose the path and click on launch

2. Importing the spring boot project

Once your eclipse IDE is open,

  • Click on File →Import , which will open up an import window
  • Type in Maven and select “Existing Maven Projects” and click Next
  • Now click on browse button and navigate to the Spring boot project location and select the folder where we unzipped the SpringBootDemo project. Once you select and click ok, the window should identify the pom.xml file and show as below. Click Finish
  • Give it couple of minutes to import all the required maven dependencies. You can see the progress bar in the bottom left corner of eclipse as shown below. Wait for it to complete
  • Once its imported, you will be the project structure as shown below in your project explorer

Following are the three important files or paths that you will need most of the time. We will go through the details of each in other posts

  1. The src/main/java path will contain java class files. There will already be a default <ProjectName>Application.java file which is your springboot starting file
  2. application.properties inside the src/main/resources path where you will be able to configure the application properties like application name, ports db urls etc
  3. pom.xml file which will be the file where you will configure all maven dependencies that are needed for your project.

3. Running the Spring boot project

You can right click the project or the SpringBootDemoApplication.java file and run as java application or Spring boot application

And you will see the spring boot application starting in console of your eclipse. As shown below.

When i ran the program initially, you might also encounter an exception like shown above.

Exception: Application Failed to Start : Web server failed to start: Port 8080 is already in use.

This is because, spring boot tries to start in the default 8080 port and your machine might already have other services running on the 8080 port.

There are two things that we do usually to fix this exception:

a. We can configure a new port in application.properties ( i will keep this for another post )

b. we can kill the service that is running on port 8080 and re-run our spring boot application.

For this tutorial, we will kill the service running on port 8080 following the instructions given in the article How to kill process running on port 8080

Once you kill the service, rerun the spring boot application in eclipse and the service should start.

If you go to your browser and load http://localhost:8080/ it will give you a white-label error. But no need to panic. your project is running properly. Its just that it doesn't have anything to load.

--

--

gautham
Eat-Sleep-Code-Repeat

Avid Reader || Blogger || Tech Enthusiast || Working as an Engineering Manager at Atlassian