How to create a basic application in Java Spring Boot
Last Updated :
08 Nov, 2023
Spring Boot is the most popular Java framework that is used for developing RESTful web applications. In this article, we will see how to create a basic Spring Boot application.
Spring Initializr is a web-based tool using which we can easily generate the structure of the Spring Boot project. It also provides various different features for the projects expressed in a metadata model. This model allows us to configure the list of dependencies that are supported by JVM. Here, we will create the structure of an application using Spring Initializr and then use an IDE to create a sample GET route.
Therefore, to do this, the following steps are followed:
Step 1: Go to Spring Initializr
Fill in the details as per the requirements. For this application:
Project: Maven
Language: Java
Spring Boot: 3.1.5
Packaging: JAR
Java: 17
Dependency: Spring Web
IDE: IntelliJ IDEA
NOTE: For creating a simple application in Java Spring Boot we can import our code directly into various IDEs:
- Spring Tool Suite(STS)
- IntelliJ IDEA
- VSCode
Here, we have used IntelliJ IDEA for creating a basic Spring Boot application
Step 2: Specify Group Id and Artifact Id. Here we have provided the Group name as "com.gfg" and the Artifact ID as "Spring Boot app".
Step 3: Click on Generate which will download the starter project.

Step 4: Extract the zip file. Now open a suitable IDE and then go to File->New->Project from existing sources->Spring-boot-app and select pom.xml. Click on import changes on prompt and wait for the project to sync.

Note: In the Import Project for Maven window, make sure you choose the same version of JDK which you selected while creating the project.
Step 5: Go to src->main->java->com.gfg.Spring.boot.app, create a java class with name as Controller and add the annotation @RestController. Now create a GET API as shown below:
Java
@RestController
public class Controller {
// One syntax to implement a
// GET method
@GetMapping("/")
public String home()
{
String str
= "<html><body><font color=\"green\">"
+ "<h1>WELCOME To GeeksForGeeks</h1>"
+ "</font></body></html>";
return str;
}
// Another syntax to implement a
// GET method
@RequestMapping(
method = { RequestMethod.GET },
value = { "/gfg" })
public String info()
{
String str2
= "<html><body><font color=\"green\">"
+ "<h2>GeeksForGeeks is a Computer"
+ " Science portal for Geeks. "
+ "This portal has been "
+ "created to provide well written, "
+ "well thought and well explained "
+ "solutions for selected questions."
+ "</h2></font></body></html>";
return str2;
}
}
Step 6: This application is now ready to run. Run the SpringBootAppApplication class and wait for the Tomcat server to start.

Note: The default port of the Tomcat server is 8080 and can be changed in the application.properties file.
Step 7: Now go to the browser and enter the URL localhost:8080. Observe the output and now do the same for localhost:8080/gfg
Output
On running the above application, the following output is generated:
Conclusion
By following the above steps, we have created a simple RESTful route with some message in it. In order to make a more complex application, more RESTful routes are added to perform the CRUD operations on the server.
Similar Reads
Spring Boot Tutorial
Spring Boot is a Java framework that makes it easier to create and run Java applications. It simplifies the configuration and setup process, allowing developers to focus more on writing code for their applications. This Spring Boot Tutorial is a comprehensive guide that covers both basic and advance
10 min read
Introduction to Spring Boot
Spring is widely used for creating scalable applications. For web applications, Spring provides Spring MVC, a commonly used module for building robust web applications. The major drawback of traditional Spring projects is that configuration can be time-consuming and overwhelming for new developers.
5 min read
Best Way to Master Spring Boot â A Complete Roadmap
In the corporate world, they say "Java is immortal!". But Why? Java remains one of the major platforms for developing enterprise applications. Enterprise Applications are used by large companies to make money. Those applications have high-reliability requirements and an enormous codebase. According
14 min read
How to Create a Spring Boot Project?
Spring Boot is built on top of the spring and contains all the features of spring. It is one of the most popular frameworks for building Java-based web applications and microservices. It is a favorite among developers due to its rapid, production-ready environment, which allows developers to focus o
6 min read
Spring Boot - Annotations
Spring Boot Annotations are a form of metadata that provides data about a spring application. Spring Boot is built on the top of the spring and contains all the features of spring. And is becoming a favorite of developers these days because of its rapid production-ready environment which enables the
7 min read
Spring Boot - Architecture
Spring Boot is built on top of the core Spring framework. It simplifies and automates Spring-based application development by reducing the need for manual configuration. Spring Boot follows a layered architecture, where each layer interacts with other layers in a hierarchical order. The official Spr
3 min read
Spring Boot Actuator
Developing and managing an application are the two most important aspects of the applicationâs life cycle. It is very important to know what is going on beneath the application. Also, when we push the application into production, managing it gradually becomes critically important. Therefore, it is a
5 min read
Spring Boot - Introduction to RESTful Web Services
RESTful Web Services REST stands for REpresentational State Transfer. It was developed by Roy Thomas Fielding, one of the principal authors of the web protocol HTTP. Consequently, REST was an architectural approach designed to make the optimum use of the HTTP protocol. It uses the concepts and verbs
5 min read
How to create a basic application in Java Spring Boot
Spring Boot is the most popular Java framework that is used for developing RESTful web applications. In this article, we will see how to create a basic Spring Boot application.Spring Initializr is a web-based tool using which we can easily generate the structure of the Spring Boot project. It also p
3 min read
How to Create a REST API using Java Spring Boot?
Representational State Transfer (REST) is a software architectural style that defines a set of constraints for creating web services. RESTful web services allow systems to access and manipulate web resources through a uniform and predefined set of stateless operations. Unlike SOAP, which exposes its
4 min read