Spring Mvc Spring Mybatis fully annotated transaction configuration, service layer transactions are not rolled back

In spring-context.xml, the configuration does not scan Coontroller
	<!-- Use Annotation to automatically register beans to solve the problem of transaction failure: @Controller annotations are not scanned in the main container, and only @Controller annotations are scanned in SpringMvc. -->
	<context:component-scan base-package="com.pds.j2ee"><!-- base-package
			If there are multiple, separate them with "," -->
		<context:exclude-filter type="annotation"
			expression="org.springframework.stereotype.Controller" />
	</context:component-scan>
In Spring-mvc.xml, the configuration only scans the Controller
	<!-- Use Annotation to automatically register beans, only scan @Controller -->
	<context:component-scan base-package="com.pds.j2ee" use-default-filters="false"><!-- If there are multiple base-packages, separate them with "," -->
		<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
	</context:component-scan>
PS: Also note that if multiple things are configured in the configuration file, you need to specify the name of the thing when annotating things in the Service layer
@Transactional("transactionManager3")
The weight of the service layer method cannot be fast with try catch, otherwise things will not be rolled back, and throws Exception is required

Guess you like

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