spring mvc - springmvc freemarker Could not autowire field freeMarkerConfigurer -


springmvc4.2.4 + mybatis3.2.8 work well,it couldn't autowire after add freemarker2.2.23.the exception caused freemarker

console

caused by: org.springframework.beans.factory.beancreationexception: not autowire field: private org.springframework.web.servlet.view.freemarker.freemarkerconfigurer com.water.controller.htmlgencontroller.freemarkerconfigurer; nested exception org.springframework.beans.factory.nosuchbeandefinitionexception: no qualifying bean of type [org.springframework.web.servlet.view.freemarker.freemarkerconfigurer] found dependency: expected @ least 1 bean qualifies autowire candidate dependency. dependency annotations: {@org.springframework.beans.factory.annotation.autowired(required=true)}     @ org.springframework.beans.factory.annotation.autowiredannotationbeanpostprocessor$autowiredfieldelement.inject(autowiredannotationbeanpostprocessor.java:573)     @ org.springframework.beans.factory.annotation.injectionmetadata.inject(injectionmetadata.java:88)     @ org.springframework.beans.factory.annotation.autowiredannotationbeanpostprocessor.postprocesspropertyvalues(autowiredannotationbeanpostprocessor.java:331)     ... 22 more caused by: org.springframework.beans.factory.nosuchbeandefinitionexception: no qualifying bean of type [org.springframework.web.servlet.view.freemarker.freemarkerconfigurer] found dependency: expected @ least 1 bean qualifies autowire candidate dependency. dependency annotations: {@org.springframework.beans.factory.annotation.autowired(required=true)}     @ org.springframework.beans.factory.support.defaultlistablebeanfactory.raisenosuchbeandefinitionexception(defaultlistablebeanfactory.java:1373)     @ org.springframework.beans.factory.support.defaultlistablebeanfactory.doresolvedependency(defaultlistablebeanfactory.java:1119)     @ org.springframework.beans.factory.support.defaultlistablebeanfactory.resolvedependency(defaultlistablebeanfactory.java:1014)     @ org.springframework.beans.factory.annotation.autowiredannotationbeanpostprocessor$autowiredfieldelement.inject(autowiredannotationbeanpostprocessor.java:545)     ... 24 more 

web.xml:

<context-param>         <param-name>contextconfiglocation</param-name>         <param-value>classpath:spring/applicationcontext-*.xml</param-value>   </context-param>    <listener>         <listener-class>org.springframework.web.context.contextloaderlistener</listener-class>     </listener>      <servlet>         <servlet-name>wmall-manager</servlet-name>         <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class>          <init-param>             <param-name>contextconfiglocation</param-name>             <param-value>classpath:spring/spring-mvc.xml</param-value>         </init-param>         <load-on-startup>1</load-on-startup>     </servlet>     <servlet-mapping>         <servlet-name>abc</servlet-name>         <url-pattern>/</url-pattern>     </servlet-mapping> 

spring-mvc.xml

<context:property-placeholder location="classpath:config/resource*.properties"/>     <context:component-scan base-package="com.abc"/>     <mvc:annotation-driven/>     <mvc:default-servlet-handler/>  <!--freemarker-->     <bean id="freemarkerconfig" name="freemarkerconfig"           class="org.springframework.web.servlet.view.freemarker.freemarkerconfigurer">         <property name="templateloaderpath" value="web-inf/ftl/" />         <property name="defaultencoding" value="utf-8" />     </bean>     <bean class="org.springframework.web.servlet.view.internalresourceviewresolver">         <property name="prefix" value="/web-inf/jsp/"/>         <property name="suffix" value=".jsp"/>     </bean> 

controller:

@autowired private freemarkerconfigurer freemarkerconfigurer; 

remove autowired code controller,work well

just move code that

<!--freemarker--> <bean id="freemarkerconfig" name="freemarkerconfig"  class="org.springframework.web.servlet.view.freemarker.freemarkerconfigurer">     <property name="templateloaderpath" value="web-inf/ftl/" />     <property name="defaultencoding" value="utf-8" /> </bean> 

from spring-mvc.xml(dispatcherservlet) applicationcontext.xml ,it work. don't know why work place code in spring-mvc.xml.


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -