Mustache + Spring Boot:Quick start

Today, we will go through how to develop a Spring Boot web application using the Mustache template engine and package it as an executable JAR file.

Following technologies stack being used:
  • Spring Boot 2.1.1.RELEASE
  • Spring 5.1.3.RELEASE 
  • Maven 3
  • JDK 1.8
  • Eclipse Oxygen
  • Mustache

1. Project Structure

2. Dependency Management [pom.xml]

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns=""
<!-- lookup parent from repository -->
<description>Demo project for Springboot-mustache</description>
<!-- spring mvc, rest -->

3. Controller

package com.knowledgefactory.knowledgefactorydemo;

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

public class HomeController {
@GetMapping({ "/", "/welcome" })
public String hello(Model model) {
return "index";

4. Spring Boot

package com.knowledgefactory.knowledgefactorydemo;

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

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

5. View Template

<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<title>Hello Mustache</title>
<h2 class="hello-title">Hello Mustache</h2>



Popular posts from this blog

Learn Java 8 streams with an example - print odd/even numbers from Array and List

Java Stream API - How to convert List of objects to another List of objects using Java streams?

Spring Boot + Mockito simple application with 100% code coverage

Registration and Login with Spring Boot + Spring Security + Thymeleaf

Java, Spring Boot Mini Project - Library Management System - Download

Spring boot video streaming example-HTML5

ReactJS, Spring Boot JWT Authentication Example

Java - Blowfish Encryption and decryption Example

Custom Exception Handling in Quarkus REST API

Spring Boot + OpenCSV Export Data to CSV Example