Spring Boot - Spring Boot FreeMarker War packaging

The following example shows how to package FreeMarker based Spring Boot application as war so that it can be deployed to a Servlet container server. Also check out our FreeMarker Jar packaging Boot tutorial here.


<project .....>

Boot main config class

public class ExampleMain extends SpringBootServletInitializer {
  protected SpringApplicationBuilder configure (SpringApplicationBuilder builder) {
      return builder.sources(ExampleMain.class);

  public static void main(String[] args) throws InterruptedException {, args);

To run as war via tomcat maven plugin (included in pom.xml):

mvn tomcat7:run-war


Example Project

Dependencies and Technologies Used:

  • Spring Boot 1.5.9.RELEASE
    Corresponding Spring Version 4.3.13.RELEASE
  • spring-boot-starter-freemarker : Starter for building MVC web applications using FreeMarker views.
  • spring-boot-starter-tomcat : Starter for using Tomcat as the embedded servlet container. Default servlet container starter used by spring-boot-starter-web.
  • JDK 1.8
  • Maven 3.3.9

spring-boot-freemarker-war-example Select All Download
  • spring-boot-freemarker-war-example
    • .settings
    • src
      • main
        • java
          • com
            • logicbig
              • example
        • resources
          • templates

See Also