title: Thymleaf Template not being used properly within spring boot
body: <p>I'm having trouble to set up properly my spring boot application.</p>
  
  <p>Basically I have this pom.xml :</p>
  
  <pre><code>&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.3.RELEASE&lt;/version&gt;
      &lt;relativePath /&gt;
  &lt;/parent&gt;
  
  &lt;properties&gt;
      &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
      &lt;java.version&gt;1.8&lt;/java.version&gt;
  &lt;/properties&gt;
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-hateoas&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-jdbc&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &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;
      &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;dependency&gt;
          &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
          &lt;artifactId&gt;spring-security-ldap&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-actuator&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-thymeleaf&lt;/artifactId&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>and this web app configuration :</p>
  
  <pre><code>@Configuration
  public class WebConfig extends WebMvcConfigurerAdapter {
  
  @Override
  public void addResourceHandlers(ResourceHandlerRegistry registry) {
      registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
  }
  
  @Override
  public void addViewControllers(ViewControllerRegistry registry) {
      registry.addViewController("/login").setViewName("security/login");
  }
  
  @Bean
  public ViewResolver viewResolver() {
      ThymeleafViewResolver resolver = new ThymeleafViewResolver();
      resolver.setTemplateEngine(templateEngine());
      resolver.setCharacterEncoding("UTF-8");
      return resolver;
  }
  
  @Bean
  public SpringTemplateEngine templateEngine() {
      SpringTemplateEngine templateEngine = new SpringTemplateEngine();
  
      Set&lt;IDialect&gt; dialects = new HashSet&lt;IDialect&gt;();
      dialects.add(springSecurityDialect());
  
      templateEngine.setAdditionalDialects(dialects);
      templateEngine.setTemplateResolver(templateResolver());
      return templateEngine;
  }
  
  @Bean
  public SpringSecurityDialect springSecurityDialect() {
      SpringSecurityDialect dialect = new SpringSecurityDialect();
      return dialect;
  }
  
  @Bean
  public TemplateResolver templateResolver() {
      SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
      resolver.setPrefix("templates/");
      //resolver.setSuffix(".html");
      return resolver;
  }
  }
  </code></pre>
  
  <p>On the ressources side I've the following : </p>
  
  <pre><code>/src
  --/main
  ----/resources
  ------/template
  --------/home
  ----------/home.html
  --------/security
  ----------/login.html
  </code></pre>
  
  <p>I also have this one class :</p>
  
  <pre><code>@Configuration
  @EnableWebSecurity
  public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
  
  @Autowired
  JdbcTemplate jdbcTemplate;
  
  @Override
  protected void configure(HttpSecurity http) throws Exception {
      http
              .authorizeRequests()
                  .antMatchers("/", "/home").permitAll()
              .and()
                  .formLogin().loginPage("/login").failureUrl("/login?error")
                  .usernameParameter("username").passwordParameter("password")
              .and()
                  .logout().logoutSuccessUrl("/login?logout")
              .and()
                  .exceptionHandling().accessDeniedPage("/403")
              .and()
                  .csrf();
  }
  
  @Autowired
  public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
      auth
          .jdbcAuthentication().dataSource(jdbcTemplate.getDataSource())
              .usersByUsernameQuery("select username,password, enabled from users where username=?")
              .authoritiesByUsernameQuery("select username, role from user_roles where username=?");
  
      ;
  }
  
  }
  </code></pre>
  
  <p>And no matter what, I can't fix nor understand the following error :</p>
  
  <pre><code>2016-08-19 11:40:58.707 ERROR 6874 --- [nio-8080-exec-1]         org.thymeleaf.TemplateEngine             : [THYMELEAF][http-nio-8080-exec-1]       Exception processing template "home/home": Error resolving template "home/home",  template might not exist or might not be accessible by any of the configured   Template Resolvers
  2016-08-19 11:40:58.723 ERROR 6874 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[.[dispatcherServlet]      : Servlet.service() for servlet [dispatcherServlet] in context with path [/fidzit] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: Error resolving template "home/home", template might not exist or might not be accessible by any of the configured Template Resolvers] with root cause
  org.thymeleaf.exceptions.TemplateInputException: Error resolving template "home/home", template might not exist or might not be accessible by any of the configured Template Resolvers
  at org.thymeleaf.TemplateRepository.getTemplate(TemplateRepository.java:246) ~[thymeleaf-2.1.4.RELEASE.jar:2.1.4.RELEASE]
  at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1104) ~[thymeleaf-2.1.4.RELEASE.jar:2.1.4.RELEASE]
  at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1060) ~[thymeleaf-2.1.4.RELEASE.jar:2.1.4.RELEASE]
  at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1011) ~[thymeleaf-2.1.4.RELEASE.jar:2.1.4.RELEASE]
  at 
  [...]
  </code></pre>