The reason why @Transational transaction rollback does not take effect

  • It can only be applied to public visibility methods, and you can also annotate @Transational annotations directly on the class to include the entire class in spring transaction management.

  • By default, uncheck exceptions such as network exceptions are not rolled back.

	@Transational(rollbackFor = Exception.class)
  • An exception was caught using try catch in the service layer, @Transational is invalid at this time, but a service exception can be caught in the controller layer, and @Transational is still valid at this time

  • The A method without @Transational of the same class calls the B method with @Transational, @Transational is invalid. Of course it would be fine if both had @Transational.

  • Still invalid?

    • The database does not support transactions

    • springboot does not open transaction annotations

Published 21 original articles · won 24 · views 20,000 +

Guess you like

Origin blog.csdn.net/qq_30332665/article/details/104999746