码迷,mamicode.com
首页 > 编程语言 > 详细

Spring MVC集成thymeleaf时提示:defined in ServletContext resource [/WEB-INF/SrpingMVCTest-servlet.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException

时间:2017-09-14 13:19:23      阅读:306      评论:0      收藏:0      [点我收藏+]

标签:char   context   text   code   odex   utf-8   framework   ati   contex   

错误提示:

defined in ServletContext resource [/WEB-INF/SrpingMVCTest-servlet.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.thymeleaf.templateresolver.ServletContextTemplateResolver]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.thymeleaf.templateresolver.ServletContextTemplateResolver.<init>()

解决方法:

由于是从2.0版本升到3.0版本的原因,写法变了,应该在Bean上这样注入:

    <!-- thymeleaf -->
    <bean id="templateResolver" class="org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver">  
      <property name="prefix" value="/WEB-INF/templates/" />  
      <property name="suffix" value=".html" />  
      <property name="templateMode" value="HTML" />  
      <property name="cacheable" value="false" />  
    </bean>  
        
    <bean id="templateEngine" class="org.thymeleaf.spring4.SpringTemplateEngine">  
      <property name="templateResolver" ref="templateResolver" />  
    </bean>  
    
    <bean class="org.thymeleaf.spring4.view.ThymeleafViewResolver">  
      <property name="templateEngine" ref="templateEngine" />  
      <!--解决中文乱码-->  
      <property name="characterEncoding" value="UTF-8"/>  
    </bean>

 

参考:

https://stackoverflow.com/questions/38057341/failed-to-instantiate-org-thymeleaf-templateresolver-servletcontexttemplatereso

Spring MVC集成thymeleaf时提示:defined in ServletContext resource [/WEB-INF/SrpingMVCTest-servlet.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException

标签:char   context   text   code   odex   utf-8   framework   ati   contex   

原文地址:http://www.cnblogs.com/EasonJim/p/7519817.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!