A requirement, originally planned to use multi-threading to insert multiple libraries separately, buried int a=1/0 to test the rollback, and found that there was no rollback
If you want to manually control the submission of transactions, you have to start multiple transactions yourself, manually write sql, manually submit and rollback, and the cost is relatively high. What's the best way?
Later, it was changed to a single-threaded call to the @Transactional method of the service, but the result was that the pit was not rolled back
Reason: The thread calls the method of its own class, and does not use the proxy class of spring aop, so it just executes an ordinary method.
Solution: Inject a service with @Resource, and then use the thread to call the service method, so that's it