About the Springboot use Junit test, how to control test data Commit and Rollback

To ensure Springboot framework rollback data, the transaction manager database requires needs to be controlled by a transaction managed by the Spring framework, in addition, the test class needs to add transaction comment.

 

 

Which @Transactional the annotation should be directly added to the class, @Rollback annotations can be added on in the class can also be applied to the method of rollback. Such a transaction would test controlled by spring, and rolled back by @Rollback to specify, for those who want the data off the library, then add @Commit comment on it

 

Reference material

1. https://www.cnblogs.com/zhengwangzw/p/9323365.html

Guess you like

Origin www.cnblogs.com/zad27/p/11683715.html