Spring combat: Transactional annotation does not roll back the cause

Use Transactional annotation is not rolled back when using Spring, generally these may be the following reasons:

  1. Check your method is not public.

  2. Your type is not abnormal unchecked exceptions.
    I want to check if an exception would also like to roll back how to do, annotations above stated exception type can be.
    @Transactional (rollbackFor = Exception.class)
    There are similar norollbackFor, custom exception does not roll back.

  3. To support transactional database engine, if it is mysql, pay attention to the table to use engine support services, such as innodb, if it is myisam, the transaction does not work.

  4. Whether to open the parsing of annotations

<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>
  1. Scan this spring whether to your package, the following is scanned org.test following package
<context:component-scan base-package="org.test" ></context:component-scan>

These are the situations that may arise think, have the add.

Published 19 original articles · won praise 67 · views 20000 +

Guess you like

Origin blog.csdn.net/m1090760001/article/details/104583581