java - Manual configuration equivalent to mvc:annotation-driven -
this question has answer here:
- howto rid of <mvc:annotation-driven />? 4 answers
what equivalent manual configuration mvc:annotation-driven in spring mvc? because webapp implements requestmappinghandlermapping, cannot use mvc:annotation-driven have configure myself.
specifically i'm wondering configuration has included in order @async annotation work. not sure if atm. i'm starting background task @ startup supposed run long webapp running , seems me whole server waits (never-ending) method finish. @async-method in worker-service gets called service on @postconstruct.
here 2 classes:
@service public class moduledirectorywatcher{ @autowired moduledirectorywatcherworker worker; @postconstruct public void startwatching() { worker.startwatching(); } } @service public class moduledirectorywatcherworker { @async public void startwatching() { createplugindir(); initializeclassloader(); initializewatcher(); watch(); } }
the relevant part of applicationcontext.xml looks far:
<bean name="handleradapter" class="org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter"> <property name="messageconverters"> <list> <bean class="org.springframework.http.converter.bytearrayhttpmessageconverter"</bean> <bean class="org.springframework.http.converter.stringhttpmessageconverter"></bean> <bean class="org.springframework.http.converter.resourcehttpmessageconverter"></bean> <bean class="org.springframework.http.converter.xml.sourcehttpmessageconverter"></bean> <bean class="org.springframework.http.converter.xml.xmlawareformhttpmessageconverter"></bean> <bean class="org.springframework.http.converter.xml.jaxb2rootelementhttpmessageconverter"></bean> <bean class="org.springframework.http.converter.json.mappingjacksonhttpmessageconverter"></bean> </list> </property> </bean> <bean name="handlermapping" class="com.coderunner.caliope.module.api.impl.modulehandlermapping"> </bean>
now feel silly... in order work, @async , @scheduled need
<task:annotation-driven executor="myexecutor" scheduler="myscheduler" /> <task:executor id="myexecutor" pool-size="5" /> <task:scheduler id="myscheduler" pool-size="10" />
even if don't use
maybe helps out there
Comments
Post a Comment