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:
MVC + mybatis + Spring AOP Declarative Transaction management does not work "title=" Spring MVC + mybatis + Spring AOP Declarative Transaction management does not work ">
2, Springmvc.xml configuration:
MVC + mybatis + Spring AOP Declarative Transaction management does not work "title=" Spring MVC + mybatis + Spring AOP Declarative Transaction management does not work ">
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:
MVC + mybatis + Spring AOP Declarative Transaction management does not work "title=" Spring MVC + mybatis + Spring AOP Declarative Transaction management does not work ">
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:
Mvc+MyBatis+SpringAOP declarative transaction management does not work "title=" SpringMvc+MyBatis+SpringAOP declarative Transaction management has no effect ">
modified in Springmvc.xml:
Mvc+MyBatis+SpringAOP declarative transaction management does not work "title=" SpringMvc+MyBatis+SpringAOP declarative Transaction management has no effect ">
Restart the server, invoke the transaction test method, and the result can successfully start the transaction and rollback on error, configuration complete.
Mvc+MyBatis+SpringAOP declarative transaction management does not work "title=" SpringMvc+MyBatis+SpringAOP declarative Transaction management has no effect ">
collation of the relatively rough, the code to share to everyone, "
Source Address acquisition"
Spring MVC + MyBatis + Spring AOP Declarative Transaction management has no effect