In a recent project, the use of SPRINGMVC, MyBatis, found a very annoying problem: transaction management does not work!! Online access to a large number of information, tried various solutions, also failed to solve the problem!
Spring Version: 3.0.5
MyBatis Version: 3.2.2
1, applicationcontext.xml configuration:
2, Springmvc.xml configuration:
As a result of the previous SPRINGMVC, the principle of smattering, has been to consider whether the AOP configuration error and so on unrelated issues, the results of wasted effort, failed to solve!
Today, by chance to see an article, quite enlightening:
According to the above, modify the configuration file, the service scanning in the Applicationcontext.xml, the controller's scan in the Springmvc.xml,
Added in Applicationcontext.xml:
Modified in Springmvc.xml:
Restart the server, invoke the transaction test method, and the result can successfully start the transaction and rollback on error, configuration complete.
collation of the relatively rough, the code to share to everyone, "
Source Address Get "
Spring MVC + MyBatis + Spring AOP Declarative Transaction management has no effect