spring 的web.xml的加载顺序

  注意web.xml的执行顺序  context-param -> listener -> filter -> servlet  
      避免在SpringMVC中启用 service注解,否则Spring管理不了数据库事物
         <context:component-scan base-package="com.sing.service" />
         如下为线上指出注解用于何处切com.sing.service 允许用Service

<context:component-scan base-package="com.sing.service" >
   <context:include-filter type="annotation" expression="org.springframework.stereotype.Service"/>
   <!-- 拦截所有的在service层使用 @service注解的类  主要是为了层级更加清晰以及避免注解乱用-->
   <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
原文地址:https://www.cnblogs.com/zyzg/p/7843203.html