spring+springMvc+mybatis

1.spring+springMvc+mybatis configure the control of things, just add in application.xml

 

 

<bean id="transManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<property name="dataSource" ref="dataSource"></property>
	</bean>
<tx:annotation-driven transaction-manager="transManager"/>

 I thought it would be done soon, so I tested it. When an exception occurs, things do not roll. I found a lot of information on the Internet. It is said that the class generated by the aspect class is not a proxy class, and the called class must also be a proxy class. But why is the @service I annotated not a proxy class? I have always been in doubt, and finally I saw a post and finally found the result.

 

The problem is in the springMvc configuration file

 

 

Original file configuration:

 

<context:component-scan base-package="com.tongli.cn2401,com.tongli.manage">

 Modified configuration:

<context:component-scan base-package="com.tongli.cn2401,com.tongli.manage">
		<context:exclude-filter type="annotation"  
            expression="org.springframework.stereotype.Service"/>
	</context:component-scan>

 

 

 After restarting, the transaction control works, and if an exception is thrown, the transaction will be rolled back.

 

The reason for the problem is that when the mvc configuration file is started, the service annotation is also scanned. Then the service class has been generated when the application configuration file is loaded, so that cglib will not proxy the service .

 

 

Link address: http://blog.csdn.net/jaedong4j/article/details/51087576

 

 

Guess you like

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