This tutorial is another article in the How to setup project series. This tutorial describes how to create a Spring Boot application. It will be a Spring Boot project with Maven and generated by Spring Initializr. This is the best way to create a Spring application, and Spring Initializr provides you a great tool for setup a spring app. In this tutorial, you will learn how to create HTTP endpoints, how to expose HTTP endpoints, how to run spring application with the command line.

Create a project with Spring boot and Maven


To complete this tutorial, you will need to have below things:

Setup the Spring Boot App with Spring Initializr :

In this tutorial, we will setup the project with the help of Spring Initializr Web UI.

Step 1 :

Go to Spring Initializr.

Spring Initializr Web UI
Spring Initializr Web UI
Step 2 :

Select Project as Maven Project, Language as Java, Spring Boot as 2.3.4.

Project, language, and Spring Boot version selection
Project, language, and Spring Boot version selection
Step 3 :

Enter details in Project Metadata.

Step 4:

Select Spring Web as dependency.

Step 5:

click on Generate button to download the project files as zip and then extract it on root directory.

Below is the code of pom.xml which took all the project setup and dependency packages info.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="" xmlns:xsi=""
		<relativePath/> <!-- lookup parent from repository -->
	<description>User Management</description>






Create Greeting.class file:

In this section, we will create a greeting.class controller file that can be exposed as an HTTP Rest API.

package com.thedevfamily.usermanagement.controllers;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

public class Greeting {
    public String greeting() {
        return "Greetings from The Dev Family";

We will inject @RestController decorator in Greeting.class. By doing this, we can convert a simple class into REST API which can be used in Spring MVC to handle web requests.

@RequestMapping maps the greeting() with API endpoint ("/") which returns a string as the response of API endpoint.

@RestController combines two annotations one is  @Controller and another one is  @ResponseBody, these two annotations that result in web requests returning data rather than a view.

Create Application.class file:

At the time of project initialization, Spring Initializr creates Application.class that have method to boot up the application. In this class, we will use @SpringBootApplication annotation for running the application.

package com.thedevfamily.usermanagement;

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

public class UsermanagementApplication {

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


Run the Application:

By running the below command in the root directory of project will boot up the application.

./mvnw spring-boot:run
Running the App

In the above screenshot, we will able to see the application is up with localhost and port will be 8080 by default. After launch the app, we will hit the api (http://localhost:8080) from browser or REST API tool like postman.

API call using Postman


After successfully complete this tutorial, we learned how to set up the project in Spring Boot with the help of Spring Initializr. In this tutorial, we learned how to expose simple API in Spring. In the next tutorial, we will learn How to create CRUD APIs in Spring. If you have any doubt regarding this tutorial or any other doubt, please reach me out to email (

Please refer the code in GitHub. First try yourself, then refer the code.

Resources :

Leave a Reply

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