Introduction to Spring Boot

In this tutorial you are going to learn what Spring Boot is and how you can start using it.



  • 10-20 minutes of your time
  • familiarity with Maven

What is Spring Boot?

Spring Boot makes the process of creating a stand-alone Spring based application very easy and simple. By using the Spring Boot Java-based framework, you will need a very insignificant amount of configuration.

If you are familiar with Spring in general, you know how massive and unmanageable the XML conifguration file in Spring becomes at some point. Well, thanks to Spring Boot, you won’t run into that issue.

Another benefit that comes when using Spring Boot is it reduces the development time significantly and provides an overall easier way of getting started with the application.


  • Very easy to deploy
  • Easy to pick up
  • Saves time
  • Not much configuration needed
  • Provides dependency management
  • Provides annotation-based spring application

Now that you know what Spring Boot is and you are familiar with the advantages it provides, let me show you how you can get started using it right away.

Building with Maven

Within your project directory, create a subdirectory.


mkdir -p src/main/java/demo

This is how your pom.xml file should look like:


<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="" xmlns:xsi=""







Please note that we are using the spring boot maven plugin. In a nutshell, it searches for the main() method, provides build-in dependency resolver which sets the version number match the Spring Boot dependencies and finally, it collects all the jars on the classpath and then build a runnable “uber-jar” which makes it more convenient to execute.

Let’s build a demo Web Application

Let’s create our controller. The path for the controller is:


package demo;

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

public class DemoController {
    public String handle() {
        return "Hello World!";

For this controller class, we are using the @RestController annotation, which if you are not familiar with, it basically makes it ready for use by Spring MVC to be able to handle web requests. Therefore, all web requests to the “/” path, will be handled by our handle() method. The reason the web requests will be handled for this particular path (“/”) is because we are using the @RequestMapping annotation which maps it to this web path.

Now is time to create our Application class.

Let’s build an DemoApplication class

Let’s create our DemoApplication class. The path for the application class is:


package demo;

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

public class Application {
	// that's the main method
    public static void main(String[] args) {, args);

Thanks to the @SpringBootApplication annotation, we are initializing the entry point of the Spring Boot Application. Notice that we have our main method in this class.

The @SpringBootApplication annotation contains @EnableAutoConfiguration, @ComponentScan and @SpringBootConfiguration. When using the @SpringBootApplication annotation, we “invoke” all of the above-mentioned annotations.

Run the application

To run the application with maven, execute the following line:

mvn package && java -jar target/gs-spring-boot-0.1.0.jar
0 0 votes
Article Rating
Inline Feedbacks
View all comments