title: In Springmvc and Thymeleaf, getting "Cannot initialize template resolver: a resource resolver has not been set]" error
body: <p>I will show some mistakes next, but first I will explain it. According to some of my output, creating ViewResolver, SpringTemplateEngine, TemplateResolver bean is no problem, and then found the home page, view name is "home", here is no problem.</p>
  
  <p>And then, according the thymeleaf template, I'll get the path "/WEB-INF/templates/home.html" . But it's wrong here. The following error occurred</p>
  
  <pre><code> Servlet.service() for servlet [dispatcher] in context with path [/Spittr] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.ConfigurationException: Cannot initialize template resolver: a resource resolver has not been set] with root cause
  org.thymeleaf.exceptions.ConfigurationException: Cannot initialize template resolver: a resource resolver has not been set
      at org.thymeleaf.templateresolver.TemplateResolver.initializeSpecific(TemplateResolver.java:136)
      at org.thymeleaf.templateresolver.AbstractTemplateResolver.initialize(AbstractTemplateResolver.java:106)
      at org.thymeleaf.Configuration.initialize(Configuration.java:200)
      at org.thymeleaf.TemplateEngine.initialize(TemplateEngine.java:831)
      at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1122)
      at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1095)
      at org.thymeleaf.spring3.view.ThymeleafView.renderFragment(ThymeleafView.java:259)
      at org.thymeleaf.spring3.view.ThymeleafView.render(ThymeleafView.java:179)
      at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1244)
      at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1027)
      at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:971)
      at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
      at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
      at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
      at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
      at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
      at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528)
      at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1100)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:687)
      at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2508)
      at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2497)
  
  at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
  at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
  at java.lang.Thread.run(Unknown Source)
  </code></pre>
  
  <p>I do not know what it means, and check a lot but do not know how to solve. I will show some bean:</p>
  
  <pre><code>@Bean
  public ViewResolver viewResolver(SpringTemplateEngine templateEngine){
      ThymeleafViewResolver viewResolver = new ThymeleafViewResolver();
      viewResolver.setTemplateEngine(templateEngine);
      System.out.println("create:viewResolver");
      return viewResolver;
  }
  
  @Bean
  public SpringTemplateEngine templateEngine(TemplateResolver templateResolver){
      SpringTemplateEngine templateEngine = new SpringTemplateEngine();
      templateEngine.setTemplateResolver(templateResolver);
      System.out.println("create:templateEngine");
      return templateEngine;
  }
  
  @Bean
  public TemplateResolver templateResolver(){
      TemplateResolver templateResolver = new TemplateResolver();
      templateResolver.setPrefix("/WEB-INF/templates/");
      templateResolver.setSuffix(".html");
      templateResolver.setTemplateMode("HTML5");
      System.out.println("create:templateResolver");
      return templateResolver;
  }
  </code></pre>
  
  <p>Following is my controller</p>
  
  <pre><code>@RequestMapping("/")
  public class HomeController {
      @RequestMapping(method=GET)
      public String home(){
          System.out.println("control:home");
          return "home";        //view name：home
      }
  }}
  </code></pre>
  
  <p>Please help me look at the above questions.</p>