New Thread (new Runnable () {@Overridepublic void Run () {//spring cannot handle the Thread's transaction, the declarative transaction is invalid Defaulttransactiondefinition def = New Defaulttransactiondefinition ();d ef.setpropagationbehavior (transactiondefinition.propagation_required); Platformtransactionmanager Txmanager = Contextloader.getcurrentwebapplicationcontext (). GetBean ( Platformtransactionmanager.class); Transactionstatus status = Txmanager.gettransaction (Def); try {Processeachplan (learn); Txmanager.commit (status);// Commit TRANSACTION} catch (Exception e) {logger.info ("Exception information:" + e.tostring ()); Txmanager.rollback (status);//ROLLBACK TRANSACTION}}). Start ();
This article is from the "13165304" blog, please be sure to keep this source http://13175304.blog.51cto.com/13165304/1952201
Spring declarative transactions cannot manage the new thread-Threading solution