注意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>

 

相关文章:

  • 2021-09-28
  • 2022-12-23
  • 2022-01-11
  • 2022-01-23
  • 2022-12-23
  • 2021-04-16
  • 2021-07-31
  • 2022-12-23
猜你喜欢
  • 2021-11-01
  • 2021-06-15
  • 2022-02-11
  • 2018-07-13
  • 2021-08-26
相关资源
相似解决方案