Spring MVC + MyBatis + Spring AOP Declarative Transaction management has no effect

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.