Spring Boot is a framework which helps in the start of development of production-ready systems, not requiring a lot of preparation or configuration of environment, application servers, etc.

You can just develop the application without or with minimal configuration. Despite the minimal configuration, you can still easily access and configure all the standard parameters that you would in a regular application. Spring Boot exploits the convention over configuration software design paradigm that attempts to decrease configuration needs by making some default configurations.

So let’s start by creating the first Spring Boot application.

For this, you need Apache Maven. Spring Boot projects are based on this framework. We will call our first Spring Boot application SpringBootFirstApp. Thus, we need to create a directory called SpringBootFirstApp in our development projects directory. 

Now, create pom.xml file which describes our project:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <description>Simplest SpringBoot project</description>
        <relativePath/> <!-- lookup parent from repository -->

Next, create the default Maven directory structure src/main/java.


Then create the class SpringBootFirstApp in the package com.zerotoherodev.tutorial.springboot. Thus, we have created a corresponding directory structure. 

package com.zerotoherodev.tutorial.springboot;

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

public class SpringBootFirstApp {

    public static void main(String[] args) {
        SpringApplication.run(SpringBootFirstApp.class, args);

Now we need to compile our project. In the main Project directory (where pom.xml exists), run command prompt shell and execute command

mvn clean package

The project is now compiled and packaged. We can find the project package in /tagert directory. Its name is springboot-tutorial-0.0.1-SNAPSHOT.jar.

At about 14 Mb, the size of our jar file is quite big. However, we can run it as an application server, so the Tomcat application server is embedded in this jar as are other spring or dependency packages classes. Therefore, we need just Java and our jar file to run our application with the application server.

Now we can start our application:

java -jar target/springboot-tutorial-0.0.1-SNAPSHOT.jar

The application starts and we can access it through a web browser at http://localhost:8080/

As our application has no logic and functionality, we will only see an error page. However, it does show that our application is running and we can proceed to real business logic development.

Currently our application does nothing meaningful, so we have to create some business functionality.


In the next post, we will create a simple Rest service that returns greetings from the application. 

Comments powered by CComment