java - How avoid calling setApplicationContext on a Spring -


i'm setting spring mvc project thymeleaf, following tutorial at: http://www.thymeleaf.org/doc/tutorials/3.0/thymeleafspring.html#spring-mvc-configuration

trying kiss code, first replaced implements applicationcontextaware , setter method @inject private applicationcontext applicationcontext. don't understand why have call setapplicationcontext() on springresourcetemplateresolver while inherits spring interface applicationcontextaware.

how avoid this?

edit: if remove templateresolver.setapplicationcontext(applicationcontext); line, exception when accessing root:

java.lang.illegalargumentexception: application context cannot null     org.thymeleaf.util.validate.notnull(validate.java:37)     org.thymeleaf.spring4.templateresource.springresourcetemplateresource.<init>(springresourcetemplateresource.java:64)     org.thymeleaf.spring4.templateresolver.springresourcetemplateresolver.computetemplateresource(springresourcetemplateresolver.java:69)     org.thymeleaf.templateresolver.abstractconfigurabletemplateresolver.computetemplateresource(abstractconfigurabletemplateresolver.java:1221)     org.thymeleaf.templateresolver.abstracttemplateresolver.resolvetemplate(abstracttemplateresolver.java:356)     org.thymeleaf.engine.templatemanager.resolvetemplate(templatemanager.java:840)     org.thymeleaf.engine.templatemanager.parseandprocess(templatemanager.java:608)     org.thymeleaf.templateengine.process(templateengine.java:1087)     org.thymeleaf.templateengine.process(templateengine.java:1061)     org.thymeleaf.spring4.view.thymeleafview.renderfragment(thymeleafview.java:335)     org.thymeleaf.spring4.view.thymeleafview.render(thymeleafview.java:189)     org.springframework.web.servlet.dispatcherservlet.render(dispatcherservlet.java:1257)     org.springframework.web.servlet.dispatcherservlet.processdispatchresult(dispatcherservlet.java:1037)     org.springframework.web.servlet.dispatcherservlet.dodispatch(dispatcherservlet.java:980)     org.springframework.web.servlet.dispatcherservlet.doservice(dispatcherservlet.java:897)     org.springframework.web.servlet.frameworkservlet.processrequest(frameworkservlet.java:970)     org.springframework.web.servlet.frameworkservlet.doget(frameworkservlet.java:861)     javax.servlet.http.httpservlet.service(httpservlet.java:622)     org.springframework.web.servlet.frameworkservlet.service(frameworkservlet.java:846)     javax.servlet.http.httpservlet.service(httpservlet.java:729)     org.apache.tomcat.websocket.server.wsfilter.dofilter(wsfilter.java:52) 

note: use latest versions: spring 4.3.3.release , thymeleaf 3.0.2.release (of course imported thymeleaf-spring4).

after re-checking missed, appears missing @configuration annotation source of spring not injecting applicationcontext springresourcetemplateresolver.


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -