This article will explain how to create a web application using Spring boot step by step from scratch .
By the end of this article, you will be able to create a Spring boot web application that uses a Spring controller and HTML pages for serving web content.

Environment Setup
Follow below steps to create a fresh Spring boot web project in Spring Tool Suite.
1. Creating project
Go to File -> New -> Spring Starter Project as shown below.
Creating Spring boot MVC projectIf you don’t find Spring Starter Project option, then select File -> New -> Project and then search for it.

2. Fill Details
Once you select Spring Starter Project, you will be presented with a list of options to fill out such as the build tool(Maven or Gradle), name of the project, Group, Artifact etc as shown below.
For this example, we will be using Maven.
If you are familiar with Maven, fill out the options as required.
If you are not familiar, then fill the name as the name of project, Artifact as springbootdemo, Group and package as com.codippa.demo.
Creating Spring boot MVC maven project

You should select Gradle as Type if you want to use it as a build tool.

Click Next.

3. Selecting modules
This is the most important step where you need to select Spring modules or dependencies we need to include in the project. Since we are creating a Spring Boot web application, we need Spring Web dependency.
In the text box, type web and select Spring Web checkbox as shown below.
Creating Spring boot MVC maven project
Click Finish.
This will create a new project whose structure is as shown below.
Spring boot MVC project structure
Dependencies in pom.xml for this project are generated as below.
pom.xml for Spring boot MVC
For a Spring boot web MVC application, only following dependency is required.
Spring boot MVC maven dependencyThat is all. Spring boot Web MVC application development environment is now configured.

Starting App Development
If you have created a project following the above steps, then search for a class DemoApplication or with the name you created the project.
This class would be located in the package name that you provided at the time of creating project and would look as below.

package com.codippa.demo;

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

public class DemoApplication {

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


This is the main class that Spring boot automatically creates.
If you run this class, it will start an embedded tomcat server listening at port 8080. This is evident from the startup logs below.
Spring boot web MVC startup
Open a browser and enter URL http://localhost:8080, you should see an error page as below.

Spring boot MVC landing error page

This is because we have not provided a default page to display.

Adding a welcome page
By default Spring boot MVC serves static content from src/main/resources/static folder and if you place a file with name index.html at this location, it will automatically be considered as the welcome page when the root URL is accessed.
Name of the file is significant.

Create index.html file at src/main/resources/static folder with the below code.

<h1>Learning Spring Boot</h1>
<h2>Hello World,</h2>
<h2>This is my first Spring Boot MVC web application</h2>

Restart the application and now when you access http://localhost:8080 in the browser, you will see

Learning Spring Boot

Hello World,

This is my first Spring Boot MVC web application

What’s next?
Till now, you have successfully configured the development environment for a Spring boot web application which is the primary requirement before learning further.
This example does not use any view templates such as Thymeleaf or JSP and does not demonstrate using controllers to expose application URLs.
Follow Spring Boot MVC using Thymeleaf example to move ahead with learning Spring boot MVC application development using Thymeleaf.

Liked the article ? Spread the word...

Leave a Reply