Transaction management: If a method implements transaction management, assuming that this method has 3 operations to insert data, then these 3 insert operations must be performed without errors until the last line of code of this method. Once a certain code appears, such as the first If the 3 insert operations are wrong, the first two insert operations will also give up the insert. In summary: All operations in this method are conjoined babies.
If a class implements transaction management, then all methods of this class implement transaction management
step 1
Add the @EnableTransactionManagement annotation to the main startup class, which is used to open the transaction management mechanism of the project
Step 2 (choose 1 from 2)
@Transactional
Annotation on the class: This annotation is added to the class, which is equivalent to adding transaction management to all methods in this class
Annotation on the method: indicates that this method has transaction management