How to create a Spring Boot project in Eclipse IDE using Maven?

By | March 30, 2023

Spring Boot is built on the top of Spring framework which means it supports all the features of Spring framework. Spring Boot makes it easy to create standalone, production-grade spring based application that you can “Just Run”. As the standard definition says, Spring Boot provides a production-ready environment, which enables developers to focus more on business logic than configuring projects, setting up servers, etc.

Maven is a build and dependency management tool from Apache Software Foundation which is based on POM (Project Object Model). It enable us to declare all the dependencies in a file called pom.xml and whenever we run the maven command it looks for all the jars and configuration an application requires in the maven central repository and add them to the application classpath.

Benefits of Maven

  1. Maven is useful in creating the right project structure.
  2. It adds the correct set of jars and configuration required by the project.
  3. It also helps in project build and deployment.
Maven Project
Fig 1- Maven Project Structure

We can create a Spring Boot project in the following ways:

  • By using Spring Initializr. To learn more about how to create a Spring Boot project using Spring Initializer, please refer to How to Create a Spring Boot Project?
  • Using STS (Spring Tool Suite)
  • Creating a Maven project and adding the Spring Boot starter dependencies.

Steps to create a Spring Boot project in Eclipse using Maven

Step 1: Create Maven Project

First we will create a Maven project in our Eclipse IDE. For this, go to File > New > Project.

Eclipse Workspace
Fig 2- New Project

Once we click on Project, Eclipse will open a project wizard, and we need to select Maven Project and click on Next.

Fig 3- Maven Project

After we click on Next, a new popup will appear asking about the project location (here, we are choosing the default eclipse-workspace location) and clicking on Next.

Fig 4- Workspace Location

Once we click Next, it will ask for the archetypes. We are choosing maven.archetype.quickstart for our project.

Maven Archetype
Fig 5- Quickstart Archetype

After we click Next, we need to add the archetype parameters, in which we need to specify groupId and artifactid.

Fig 6- Archetype Parameters

As we click on Finish, Maven will start creating the project and add the required jars and dependencies, and our Maven project gets created.

Fig 7- Maven Project

Step 2- Updating pom.xml File

In this step, we need to update our pom.xml file for converting the Maven project to Spring Boot project. We will be using the following pom.xml file.

Note: While updating the pom.xml file make sure to change the application configurations such as groupId, artifactId etc according to your project.
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="" xmlns:xsi="" xsi:schemaLocation="">



	<!-- adding starter parent -->
		<relativePath /> <!-- lookup parent from repository -->

	<!-- adding java version -->


		<!-- adding starter web dependency -->
		<!-- adding data jpa dependency -->
		<!-- adding mysql connector dependency -->
		<!-- adding starter test dependency -->

		<!-- adding plugins -->

In the above pom.xml file, we have added the spring-boot-starter-data-jpa dependency, and for configuring the jpa and database properties, we need to have We need to go to project root directories and create the following directory structure: src/main/resources. For this, go to Project Root Directory > src/main/java > Right-Click > Properties.

Fig 8- Configuring Spring Boot Project

Once we click on Properties, it will open a properties popup window where we need to click on the location icon.

Fig 9- Properties For src\main\java

At the above location, we create a directory and name it resources.

Fig 10- Resources Directory

After we have created the resources directory in src\main we have to reload the project in our Eclipse IDE. For this, we will first delete the project from only the eclipse workspace.

Fig 11- Delete Project

Once we click on Delete, a window will pop up asking about deleting projects from workspace. Make sure not to delete projects from the disc.

Fig 12- Delete Project From Workspace

Step 3- Reloading Project In Eclipse

In this step, we need to import our project into the Eclipse IDE. For this, go to File > Import.

Fig 13- Import Project

After this, we need to choose Existing Maven Projects and click Next.

Fig 14- Existing Maven Projects

Once we click on Next, we need to Browse to our application and click on Finish.

Fig 15- Browse To Application Directory

After we click Finish, our project will get imported into our IDE workspace.

Fig 16- Workspace

Above we can see our project has been imported successfully and src/main/resource directory is also imported correctly.

Step 4- Create File

In this step, we will create file which is required for spring-boot-starter-data-jpa dependency. For this, go to src/main/resources > Right-Click > New > Others.

Fig 17- Create Other Resources

After we click on Other, a popup will come where we need to choose File and click Next.

Fig 18- Select File

On clicking Next, a popup will appear where we will create a file and name it

Create File
Fig 19- file

As we click on Finish, our spring boot project structure is complete.

Spring Boot Project
Fig 20- Spring Boot Project Structure

Step 5- Configure Database

As we have added the spring-boot-starter-data-jpa and mysql-connector dependencies, we need to configure the database in our application. For this, go to the file and add the database configuration. Please make sure to update the database credentials according to your own database.
#In file we used to application configurations in key-value pair form
#For example, below server.port will act as key and 8080 will act as value

#DB Configurations

#Hibernate Dialect

#the ddl-auto=update will create the schema automatically
#this will show the running sql queries in the console window

After adding the database configuration we need to update our project. For this, go to Project Root Directory > Right-Click > Maven > Update Project.

Update Maven Project
Fig 21- Update Project

Step 6- Setting App And AppTest File

In this step, we will setup the main class file, which is required for the Spring Boot application. As we have updated the pom.xml file, we have also updated the spring-boot-starter-test dependency, which is causing the error in the file. First, we will remove the errors from To do this, we need to add the following code to our file:

package com.paulsofts.taskmanagerservices;

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

 * we have added the @SpringBootTest annotation our AppTest
 * which makes class life cycle to be managed by spring
public class AppTest 
     * Rigorous Test :-)
	void contextLoads() {

As we can see now, the errors are gone.

Spring Boot Test Class
Fig 22- AppTest Class

Now, we will configure our main class in our Spring Boot application. For this, go to file and add the following code:

package com.paulsofts.taskmanagerservices;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

public class App {
    public static void main( String[] args ){, args);

Step 7- Test Application

We have completely created the Spring Boot application using Eclipse and Maven. Now, we will test our application. For this, go to the main class (here, > Right-Click > Run As > Java Application. We can see that our application has started successfully.

Spring Boot Running Application
Fig 23- Application Running

Leave a Reply

Your email address will not be published. Required fields are marked *