Spring Boot Web + Thymeleaf Hello World Example in IntelliJ in 5 Easy Steps

This Tutorial is a quick starter for Spring Web Application using Spring Boot + ThymeLeaf, follow the below 5 easy steps to run your very first Spring Web Application in less than 5 minutes,

Step 1: Setup Spring Web Workspace using Spring Initializr

  • Open IntelliJ IDE,
  • Create New Project,
  • Select Spring Initializr
  • Select the Project SDK (I have selected Java SDK 1.8)
  • Click Next,
  • Select Project Type as Gradle Project
  • Java Version (8 in my case)
    New Spring Boot Project using Initilizr
  • Select Dependencies: Spring Web and Thymeleaf
    Select Dependencies Spring Web and Thymeleaf
  • Click Next
  • Click Finish
  • If IntelliJ prompts click on "Load Gradle Project"

Step 2: Create Sping Web Controller

Under src > main > java com.example.demo, create MyHelloController.java

package com.example.demo;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

public class MyHelloWorldController {

    public String greeting() {
        return "helloWorld";


Step 3: Create Thymeleaf HTML Page

Navigate to src > main > resources > templates and create file helloWorld.html

<html xmlns:th="http://www.thymeleaf.org">
    <title>Spring Web + Thymeleaf - Hello World Example!</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<h1>Hello World!</h1>

Step 4: Run the Spring Web Application

Navigate to src > main > java com.example.demo and open DemoApplication and Run the main method.

Step 5: View Results on Web Broswer

Now open any Web Brower (Safari, Chrome, Firefox, or Edge) and open URL: http://localhost:8080/hello-world

Hello World - Spring Web and ThymeLeaf Results

Download this project from GitHub: https://github.com/code2care/spring-web-thymeleaf-hello-world-example/tree/main/demo

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap