title: How to properly configure Velocity with Spring Boot?
body: <p>I'm new to Spring Boot, and I'm having major trouble with this. There's a short list of Velocity-related Spring Boot properties I can set in application.properties, and those are working fine. But there's a huge number of Velocity properties that I can't configure that way.</p>
  
  <p>I found <a href="https://stackoverflow.com/questions/25836695/how-to-set-velocity-template-character-encoding-with-spring-boot">this</a> question, that seems to address what I need, but it isn't working for me. When I use breakpoints within Spring Boot during program start-up, I can see the "spring.velocity.properties.*" key/value pairs being read and loaded by Spring Boot correctly--they just don't seem to affect anything. No matter what value I set them to, the Velocity run-time behavior uses the default anyway.</p>
  
  <p>What am I missing?</p>
  
  <p>EDIT:</p>
  
  <blockquote>
    <p>pom.xml</p>
  </blockquote>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;groupId&gt;docuvore&lt;/groupId&gt;
  &lt;artifactId&gt;docuvore-server&lt;/artifactId&gt;
  &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  
  &lt;parent&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
      &lt;version&gt;1.3.0.BUILD-SNAPSHOT&lt;/version&gt;
  &lt;/parent&gt;
  
  &lt;properties&gt;
      &lt;java.version&gt;1.8&lt;/java.version&gt;
  &lt;/properties&gt;
  
  &lt;dependencies&gt;
  
      &lt;!-- Core Spring Boot --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Tomcat and Spring Web MVC --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Spring Security 
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-security&lt;/artifactId&gt;
      &lt;/dependency&gt;
      --&gt;
  
      &lt;!-- Spring Data and MongoDB --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-data-mongodb&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Apache Velocity --&gt; 
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-velocity&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Project Lombok --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.projectlombok&lt;/groupId&gt;
          &lt;artifactId&gt;lombok&lt;/artifactId&gt;
          &lt;version&gt;1.16.2&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  
  &lt;!-- Additional lines to be added here... --&gt;
  
  &lt;!-- (you don't need this if you are using a .RELEASE version) --&gt;
  &lt;repositories&gt;
      &lt;repository&gt;
          &lt;id&gt;spring-snapshots&lt;/id&gt;
          &lt;url&gt;http://repo.spring.io/snapshot&lt;/url&gt;
          &lt;snapshots&gt;&lt;enabled&gt;true&lt;/enabled&gt;&lt;/snapshots&gt;
      &lt;/repository&gt;
      &lt;repository&gt;
          &lt;id&gt;spring-milestones&lt;/id&gt;
          &lt;url&gt;http://repo.spring.io/milestone&lt;/url&gt;
      &lt;/repository&gt;
  &lt;/repositories&gt;
  &lt;pluginRepositories&gt;
      &lt;pluginRepository&gt;
          &lt;id&gt;spring-snapshots&lt;/id&gt;
          &lt;url&gt;http://repo.spring.io/snapshot&lt;/url&gt;
      &lt;/pluginRepository&gt;
      &lt;pluginRepository&gt;
          &lt;id&gt;spring-milestones&lt;/id&gt;
          &lt;url&gt;http://repo.spring.io/milestone&lt;/url&gt;
      &lt;/pluginRepository&gt;
  &lt;/pluginRepositories&gt;
  &lt;/project&gt;
  </code></pre>
  
  <blockquote>
    <p>application.properties</p>
  </blockquote>
  
  <pre><code>logging.path=/logs
  #spring.velocity.resourceLoaderPath = /templates/
  #spring.velocity.checkTemplateLocation=false
  spring.velocity.properties.template.provide.scope.control = true
  spring.velocity.properties.directive.parse.max.depth = 9
  spring.velocity.properties.runtime.log = C:/logs/velocity.log
  </code></pre>
  
  <blockquote>
    <p>Application.java</p>
  </blockquote>
  
  <pre><code>package com.github.docuvore.prototype;
  
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
  import org.springframework.context.annotation.ComponentScan;
  import org.springframework.context.annotation.Configuration;
  
  @Configuration 
  @EnableAutoConfiguration
  @ComponentScan
  public class Application {
  
      public static void main(String[] args) throws Exception {
          SpringApplication.run(Application.class, args);
      }
  }
  </code></pre>
  
  <blockquote>
    <p>ExampleVelocityController.java</p>
  </blockquote>
  
  <pre><code>package com.github.docuvore.prototype.examples;
  
  import java.io.StringWriter;
  import java.util.ArrayList;
  import java.util.List;
  
  import org.apache.velocity.Template;
  import org.apache.velocity.VelocityContext;
  import org.apache.velocity.app.VelocityEngine;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RestController;
  
  @RestController
  public class ExampleVelocityController {
  
      @RequestMapping("/exampleVelocity")
      String home() {
          String result = null;
  
          VelocityEngine velocity = new VelocityEngine();
          velocity.init();
          Template template = velocity.getTemplate("src/main/resources/templates/general/htmlElement.vm");
  
          VelocityContext context = new VelocityContext();
          context.put("title", "Apache Velocity");
  
          StringWriter writer = new StringWriter();
          template.merge(context, writer);
  
          result = writer.toString();
  
          return result;
      }
  }
  </code></pre>
  
  <blockquote>
    <p>htmlElement.vm</p>
  </blockquote>
  
  <pre><code>&lt;html&gt;
  #parse ("src/main/resources/templates/general/bodyElement.vm")
  &lt;/html&gt;
  </code></pre>
  
  <blockquote>
    <p>bodyElement.vm</p>
  </blockquote>
  
  <pre><code>&lt;body&gt;
  #parse ("src/main/resources/templates/general/bodyElement.vm")
  &lt;/body&gt;
  </code></pre>