The reason why the transaction annotation @Transactional in the Springtoot framework does not work

When using a highly integrated framework like springboot, it is often difficult to find the cause when you encounter problems!
The reason why the transaction annotation @Transactional in the Springtoot framework does not work:
1. The method using the annotation must be a method modified by the public modifier (the private and protected modified methods are invalid)!
2. Use try...catch in the annotation method to catch the exception (if you need to catch the exception and want the transaction to work, you need to add: throw new RuntimeException() to the catch)!
3. The method using annotations will be useless if it is called internally by similar methods!

Guess you like

Origin blog.csdn.net/Wangdiankun/article/details/106048951