Spring Boot devtools - Triggering auto-restart based on a single file

[Last Updated: Mar 16, 2017]

Spring Boot devtools provides an option to specify a 'trigger file'. That means, this will be the only file which will kick off the application restart if we modify it. This is good when we don't want to restart frequently on each file modification.

To use this option, we need to add the following application property:


Let's see an example how to do that.

Creating Spring boot MVC application

public class MyController1 {

  public String handle(Model model) {
      model.addAttribute("msg", "from MyController1");
      return "testView1";


    <h3>Page 1</h3>
   <p> ${msg} </p>
public class MyController2 {

  public String handle(Model model) {
      model.addAttribute("msg", "from MyController2");
      return "testView2";


    <h3>Page 2</h3>
   <p> ${msg} </p>

Let's say we want to have as the trigger file:


spring.mvc.view.prefix= /WEB-INF/pages/
spring.mvc.view.suffix= .jsp

The main class:

public class ExampleMain {

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

Run the application:

 mvn spring-boot:run

Access the pages at /path1 and /path2. Modifying any file other than will not trigger the restart as shown in this video:

Example Project

Dependencies and Technologies Used:

  • Spring Boot 1.5.2.RELEASE
    Corresponding Spring Version 4.3.7.RELEASE
  • spring-boot-starter-web : Starter for building web, including RESTful, applications using Spring MVC. Uses Tomcat as the default embedded container.
  • spring-boot-devtools : Spring Boot Developer Tools.
  • spring-boot-starter-tomcat : Starter for using Tomcat as the embedded servlet container. Default servlet container starter used by spring-boot-starter-web.
  • tomcat-embed-jasper 8.5.11: Core Tomcat implementation.
  • JDK 1.8
  • Maven 3.3.9

Boot Trigger File Example Select All Download
  • boot-trigger-file
    • src
      • main
        • java
          • com
            • logicbig
              • example
        • resources
          • webapp
            • WEB-INF
              • pages

    See Also