title: Proper location of Thymeleaf views for Spring
body: <p>I am running a spring boot application with Thymeleaf. When I run the application through my IDE (IntelliJ) everything runs fine.
  However, when I run the application through the command line (<code>java -jar</code>) the views do not resolve and I get the following error:</p>
  
  <pre><code>org.thymeleaf.exceptions.TemplateInputException: Error resolving template "index", template might not exist or might not be accessible by any of the configured Template Resolvers
      at org.thymeleaf.TemplateRepository.getTemplate(TemplateRepository.java:245)
      at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1104)
      at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1060)
      at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1011)
      at org.thymeleaf.spring3.view.ThymeleafView.renderFragment(ThymeleafView.java:335)
      at org.thymeleaf.spring3.view.ThymeleafView.render(ThymeleafView.java:190)
      at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1225)
      at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1012)
      at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
  </code></pre>
  
  <p>Here are my settings:</p>
  
  <p>My Directory Structure</p>
  
  <pre><code>PROJECT-ROOT
    --src
      --main
        --java
          --controllers
            --[CLASS WITH MAIN METHOD]
          --views
            --index.html
  </code></pre>
  
  <p>My template resolver:</p>
  
  <pre><code>@Bean
    public ViewResolver viewResolver() {
      ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver();
      templateResolver.setTemplateMode("XHTML");
      templateResolver.setPrefix("views/");
      templateResolver.setSuffix(".html");
      SpringTemplateEngine engine = new SpringTemplateEngine();
      engine.setTemplateResolver(templateResolver);
  
      ThymeleafViewResolver viewResolver = new ThymeleafViewResolver();
      viewResolver.setTemplateEngine(engine);
      return viewResolver;
    }
  </code></pre>
  
  <p>Where should I put the views so that they can be correctly resolved when ran from a jar file?</p>