title: Spring Boot templates not resolved
body: <p>I'm trying to build a standalone web application using Spring Boot and Thymeleaf. The application runs fine from IntelliJ IDEA, but I'm not able to run the jar on its own. Apparently the templates are not included.</p>
  
  <p>My project is structured as follows:</p>
  
  <pre><code>├── src
  │   └── main
  │       ├── java
  │       │   └── my
  │       │       └── domain
  │       │           └── application
  │       │               ├── domain
  │       │               ├── service
  │       │               ├── web
  │       │               ├── ApplicationConfig.java
  │       │               ├── SecurityConfig.java
  │       │               ├── ThymeleafConfig.java
  │       │               └── WebConfig.java
  │       ├── resources
  │       │   ├── application.properties
  │       │   └── log4j.properties
  │       └── webapp
  │           ├── resources
  │           │   ├── jquery.js
  │           │   └── style.css
  │           └── WEB-INF
  │               └── views
  │                   ├── layout.html
  │                   ├── login.html
  │                   └── menu.html
  └── pom.xml
  </code></pre>
  
  <p>ApplicationConfig:</p>
  
  <pre><code>@Bean
  public DataSource dataSource() {
      ...
  }
  
  @Bean
  public SessionBean sessionBean() {
      return new SessionBean();
  }
  
  public static void main(String[] args) {
      SpringApplication.run(ApplicationConfig.class, args);
  }
  </code></pre>
  
  <p>ThymeleafConfig:</p>
  
  <pre><code>@Bean
  public TemplateResolver templateResolver(){
      ServletContextTemplateResolver templateResolver = new ServletContextTemplateResolver();
      templateResolver.setPrefix("/WEB-INF/views/");
      templateResolver.setSuffix(".html");
      templateResolver.setTemplateMode("HTML5");
      return templateResolver;
  }
  
  @Bean
  public SpringTemplateEngine templateEngine(){
      SpringTemplateEngine templateEngine = new SpringTemplateEngine();
      templateEngine.setTemplateResolver(templateResolver());
      templateEngine.addDialect(new LayoutDialect());
      return templateEngine;
  }
  
  @Bean
  public ViewResolver viewResolver(){
      ThymeleafViewResolver viewResolver = new ThymeleafViewResolver() ;
      viewResolver.setTemplateEngine(templateEngine());
      viewResolver.setOrder(1);
      return viewResolver;
  }
  </code></pre>
  
  <p>WebConfig:</p>
  
  <pre><code>@Override
  public void addResourceHandlers(ResourceHandlerRegistry registry) {
      registry.addResourceHandler("/resources/**")
              .addResourceLocations("/resources/");
  }
  </code></pre>
  
  <p>I managed to include the WEB-INF folder by adding it as resource in pom.xml, but the views are still not resolved.</p>