springboot project add transaction

1. Add @EnableTransactionManagement to the startup class

2. Add @Transactional on the method / class that needs to add a transaction

 

Precautions:

Do not catch exceptions in the method of adding transactions, otherwise you cannot roll back. The correct approach is to throw the exception and handle the exception where the method is called

 

Published 3 original articles · liked 0 · visits 31

Guess you like

Origin blog.csdn.net/w_jiayou/article/details/105490543