Notice: Constant WP_MEMORY_LIMIT already defined in /home/javawith/public_html/ on line 107

Notice: Constant WP_MAX_MEMORY_LIMIT already defined in /home/javawith/public_html/ on line 108
Spring Boot Thymeleaf example - CodesJava


Easy learning with example program codes

Spring Boot Thymeleaf Hello World

Notice: Undefined variable: footnotelist in /home/javawith/public_html/ on line 475

Spring Boot Thymeleaf Hello World

Directory Structure

Spring security

pom.xml file

Modify auto created POM file. We need to add parent in pom to make it a spring boot application. After that add spring-boot-starter-thymeleaf dependency and java version.

<project xmlns="" xmlns:xsi=""
	<!-- hot swapping, disable cache for template, enable live reload -->
			<!-- Package as an executable jar or war -->

Now, right click on project -> click on Maven -> click on update project -> Popup window will open -> click Ok to update the project.
It is a initializer class which runs a SpringApplication.

package com.codesjava;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
public class App extends SpringBootServletInitializer {
	protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
		return application.sources(App.class);
    public static void main( String[] args ) {, args);  

package codesjava;
import java.util.Map;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
public class HelloWorldController {
	private String message = "Hello World";
	public String welcome(Map<String, Object> model) {
		model.put("message", this.message);
		return "helloWorld";


<!DOCTYPE html>
<html xmlns:th="">
<title>Insert title here</title>
<h2>Spring Boot Web Thymeleaf Example</h2>
	<span th:text="'Message: ' + ${message}"></span>

Hit http://localhost:8080/ in the browser, following output will come.
Spring security

Please follow and like us:

Spring Tutorial

Copyright © 2019 CodesJava Protection Status