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.thymele...