Featured Article

Spring Boot Tutorial Bootstrap a Simple Application Step by Step

Kenneth Jul 13, 2026

Welcome to our comprehensive guide on how to bootstrap a simple application using Spring Boot and Bootstrap. Spring Boot is a popular Java-based framework for developing fast, standalone, production-grade applications, while Bootstrap is a popular CSS framework for designing responsive and mobile-friendly websites. In this tutorial, we'll guide you step-by-step through the process of creating a simple web application using these two powerful tools.

Spring Boot Project Structure for Clean & Scalable Code | Raghvendra Pratap posted on the topic | LinkedIn
Spring Boot Project Structure for Clean & Scalable Code | Raghvendra Pratap posted on the topic | LinkedIn

Before we dive into the tutorial, let's make sure you have the necessary prerequisites: Java Development Kit (JDK) version 8 or later, Apache Maven, and an Integrated Development Environment (IDE) like IntelliJ IDEA or Eclipse. Also, a basic understanding of Java, Spring, and HTML/CSS would be helpful. Now, let's get started!

How to Structure a Scalable Spring Boot Application | Ritesh Kumar Gupta posted on the topic | LinkedIn
How to Structure a Scalable Spring Boot Application | Ritesh Kumar Gupta posted on the topic | LinkedIn

Setting up the Project

The first step is to set up our Spring Boot project. We'll use Spring Initializr, a handy web service from start.spring.io, to generate a new Spring Boot project with the necessary configurations.

WebClient In Spring Boot
WebClient In Spring Boot

Go to start.spring.io, select 'Web' as the project type, and choose the dependencies 'Thymeleaf' and 'Bootstrap'. Click on 'GENERATE', download the zip file, and extract it to your local machine.

Structuring the Application

Spring Boot Application Properties Example - Java Code Geeks
Spring Boot Application Properties Example - Java Code Geeks

Once you've set up the project, let's structure our application. Spring Boot uses a default project structure, which we'll maintain. The main components of our application will be the controller, the view (HTML template), and the CSS.

In the 'src/main/resources' directory, you'll find the 'static' and 'templates' folders. The 'static' folder will contain our Bootstrap CSS and JavaScript files, while the 'templates' folder will contain our HTML templates.

Adding Bootstrap to the Project

Spring Boot Tutorial for Beginners 7 - Spring Data JPA
Spring Boot Tutorial for Beginners 7 - Spring Data JPA

To use Bootstrap, we need to add its CSS and JavaScript files to our project. Create a new folder in 'src/main/resources/static', name it 'css', and download the Bootstrap CSS and JavaScript files into this folder.

Next, create a new file in 'src/main/resources/static/css', name it 'styles.css', and add the following code to import the Bootstrap CSS file:

```css @import url('https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css'); ```

Creating our First HTML Template

Spring Core Tutorials
Spring Core Tutorials

Now let's create our first HTML template. In the 'src/main/resources/templates' folder, create a new file, name it 'index.html', and add the following code:

```html Spring Boot Bootstrap Tutorial

Welcome to our application!

How To Work With Apache Kafka In Spring Boot?
How To Work With Apache Kafka In Spring Boot?
a table with several different types of text
a table with several different types of text
Boot flow  |  Android Open Source Project
Boot flow  |  Android Open Source Project
20 Ankle Boots Outfit Spring Styling You’ll Reuse
20 Ankle Boots Outfit Spring Styling You’ll Reuse
Muddy Boots - An Easy Spring Craft for Toddlers!
Muddy Boots - An Easy Spring Craft for Toddlers!
How to wear boots with dresses
How to wear boots with dresses
a pair of rubber boots with flowers in them coloring pages for kids, free printable
a pair of rubber boots with flowers in them coloring pages for kids, free printable
Shoe Pattern, Technical Drawing, Wedge Boot, Wedges, Boots, Pattern
Shoe Pattern, Technical Drawing, Wedge Boot, Wedges, Boots, Pattern
Was really feeling the boots today 🙌🏻🌻 I really just love fall so much 🍁  Comment “SUNFLOWER BOOTS” and I’ll DM you the link for the beginner-friendly embroidery pattern I used, the boots, and water-soluble paper. You can totally embroider your own boots! 👏🏻 It’s not as hard as you might think and my pattern has all my tips and tricks to help you do it! Trendy Dress Outfits, Water Soluble Paper, Combat Boots Embroidery Design, Embroidery Boots, Just Love, Japanese Embroidery, Trendy Dresses, Sunflower Boots, Embroidery Art
Was really feeling the boots today 🙌🏻🌻 I really just love fall so much 🍁 Comment “SUNFLOWER BOOTS” and I’ll DM you the link for the beginner-friendly embroidery pattern I used, the boots, and water-soluble paper. You can totally embroider your own boots! 👏🏻 It’s not as hard as you might think and my pattern has all my tips and tricks to help you do it! Trendy Dress Outfits, Water Soluble Paper, Combat Boots Embroidery Design, Embroidery Boots, Just Love, Japanese Embroidery, Trendy Dresses, Sunflower Boots, Embroidery Art

```

We've used Thymeleaf's 'th' namespace to include our CSS file and insert dynamic content into our HTML.

Creating the Controller

Next, let's create our controller. Spring Boot provides a ready-to-use 'Controller' class in the 'com.example.demo' package. Rename this class to 'ApplicationController'.

Our controller will have one endpoint, '/', which will return our 'index.html' template with a message.

```java @Controller public class ApplicationController { @GetMapping("/") public String home(@RequestParam(name="message", required=false, defaultValue="Spring Boot + Bootstrap") String message, Model model) { model.addAttribute("message", message); return "index"; } } ```

Running the Application

Now, let's run our Spring Boot application. If you're using an IDE, make sure you've selected the main class 'com.example.demo.DemoApplication' and run the application. If you prefer the command line, navigate to your project directory and run 'mvn spring-boot:run'.

Once the application is running, open your web browser and navigate to http://localhost:8080. You should see a simple webpage with the message 'Spring Boot + Bootstrap'.

Congratulations! You've successfully created a simple web application using Spring Boot and Bootstrap. This is just the beginning - the possibilities with these frameworks are endless!

In the future, you could add more endpoints, create complex HTML templates, or even add a database to your application. The choice is yours. Happy coding!