I am using the @Autowired annotation with spring-mvc and spring-security, it works, but the webapp start very slow, about 1 munute every time, because the spring-mvc and spring-security scan twice all autowired classes and the total count of classes about 500. Are there any suggestions to speed up the scan time? or the static xml configuration is better?
in web.xml
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/rest-servlet.xml
</param-value>
</context-param>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>rest</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>rest</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
....
in rest-sevlet.xml
<context:component-scan base-package="com.mycomp" />
<mvc:annotation-driven />
<mvc:interceptors>
....
</mvc:interceptors>
<import resource="classes/config/applicationContext-security-base.xml"/>
<import resource="classes/config/applicationContext-security.xml"/>
<import resource="classes/config/spring-aop.xml"/>
<!-- i18n -->
<import resource="classes/config/spring-locale.xml"/>