原因:未知
解决方案: 使用编程式事务
@Override
public void run() {
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
PlatformTransactionManager txManager = ContextLoader.getCurrentWebApplicationContext().getBean(PlatformTransactionManager.class);
TransactionStatus status = txManager.getTransaction(def);
try {
testDao.save(entity);
txManager.commit(status); // 提交事务
} catch (Exception e) {
System.out.println("异常信息:" + e.toString());
txManager.rollback(status); // 回滚事务
}
}