Spring transaction configuration invalid problem solving

The project uses spring+springmvc+mybatis. After the configuration, it is found that the transaction does not work, and it has been fiddling for almost a day.

 

Not much nonsense, first of all, it is found that the aspect is almost useless, only the mapper can be cut, and the service layer cannot be cut.

 

The final solution is that springmvc and spring are two configuration files, modify the scan path of spring-mvc.xml, exclude the service, and exclude the control from the scan path of spring.xml by the way. Because repeated scans will cause spring transactions to fail.

Do the following configuration:

spring-mvc.xml
    <!-- 配置扫描的包 -->
     <context:component-scan base-package="com.eifini.cms" >   
        <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" />   
        <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service" />    
    </context:component-scan> 
spring-mvc.xml
 
spring.xml
 <context:component-scan base-package="com.eifini.cms">   
    <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" />   
</context:component-scan> 
spring.xml

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324814671&siteId=291194637