FreeMarker + Spring Boot: Quick start

In this post, we will go through how to develop a Spring Boot web application using the FreeMarker template engine and package as an executable JAR file. You can download the source code at the end of this post.

Following technologies stack being used:
  • Spring Boot 2.1.1.RELEASE
  • Spring 5.1.3.RELEASE 
  • Maven 3
  • JDK 1.8
  • Eclipse Oxygen
  • Free Maker
1)Project Structure

2)Maven/Dependency Management [pom.xml] 

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


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) {
model.addAttribute("name", "");
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 ${name}!</title>

<h2 class="hello-title">Hello ${name}!</h2>


6)application. properties

spring.freemarker.template-loader-path: classpath:/templates
spring.freemarker.suffix: .ftl


$ mvn spring-boot:run


Popular posts from this blog

Spring boot video streaming example-HTML5

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

Spring Boot + Mockito simple application with 100% code coverage

Spring Boot + OpenCSV Export Data to CSV Example

Custom Exception Handling in Quarkus REST API

DataTable-Pagination example with Spring boot, jQuery and ajax

Registration and Login with Spring Boot + Spring Security + Thymeleaf

Node JS mini projects with source code - free download

Spring boot web project free download:User Registration System

Java - Blowfish Encryption and decryption Example