这个主要是辅助开发者判断你的事务配置是否生效。当然也可以去数据库直接插数据看看异常后是否回滚,另外如果没有编织成功事务,那么java代码中执行完sql操作的那条语句时数据库数据并没有变化,如果没有事务编织,执行完那条sql操作的语句就会在数据库中体现应有的变化。

以下是执行了事务编织的java程序服务端打印出的日志

2019-03-26 11:20:57,013 [http-bio-8082-exec-3] [20190326112046d20394d3571347a9a17668e5238191ac-0 - /jpark-business/hessian/feelingParkService] DEBUG org.mybatis.spring.SqlSessionUtils:28 - Creating SqlSession with JDBC Connection [jdbc:mysql://rm-wz9l1aamp2g509lkjo.mysql.rds.aliyuncs.com/cloud_syt?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true, UserName=jpark_syt@113.105.120.98, MySQL Connector Java]
 2019-03-26 11:20:57,023 [http-bio-8082-exec-3] [20190326112046d20394d3571347a9a17668e5238191ac-0 - /jpark-business/hessian/feelingParkService] DEBUG java.sql.Connection:28 - ooo Connection Opened
 2019-03-26 11:20:57,090 [http-bio-8082-exec-3] [20190326112046d20394d3571347a9a17668e5238191ac-0 - /jpark-business/hessian/feelingParkService] DEBUG org.mybatis.spring.transaction.SpringManagedTransaction:28 - JDBC Connection [jdbc:mysql://rm-wz9l1aamp2g509lkjo.mysql.rds.aliyuncs.com/cloud_syt?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true, UserName=jpark_syt@113.105.120.98, MySQL Connector Java] will be managed by Spring
 2019-03-26 11:20:57,115 [http-bio-8082-exec-3] [20190326112046d20394d3571347a9a17668e5238191ac-0 - /jpark-business/hessian/feelingParkService] DEBUG org.mybatis.spring.SqlSessionUtils:28 - Registering transaction synchronization for SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@30eee11b]
 2019-03-26 11:20:57,646 [http-bio-8082-exec-3] [20190326112046d20394d3571347a9a17668e5238191ac-0 - /jpark-business/hessian/feelingParkService] DEBUG java.sql.PreparedStatement:28 - ==>  Executing: insert into t_no_isv_park(ID, PARK_NAME, PARK_CODE) values(?, ?, ?) 
 2019-03-26 11:20:57,648 [http-bio-8082-exec-3] [20190326112046d20394d3571347a9a17668e5238191ac-0 - /jpark-business/hessian/feelingParkService] DEBUG java.sql.PreparedStatement:28 - ==> Parameters: dee16d3b908a43bc9364453400cf2ced(String), 13135(String), AOPTEST3(String)
 2019-03-26 11:20:57,675 [http-bio-8082-exec-3] [20190326112046d20394d3571347a9a17668e5238191ac-0 - /jpark-business/hessian/feelingParkService] DEBUG org.mybatis.spring.SqlSessionUtils:28 - Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@30eee11b]
 2019-03-26 11:21:48,067 [http-bio-8082-exec-3] [20190326112046d20394d3571347a9a17668e5238191ac-0 - /jpark-business/hessian/feelingParkService] DEBUG org.mybatis.spring.SqlSessionUtils:28 - Transaction synchronization closing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@30eee11b]

以下是没有进行事务编织的java服务端的执行日志

2019-03-26 11:25:44,522 [http-bio-8082-exec-3] [20190326112533b882074a31ca41bcbd6b497e4955ab88-0 - /jpark-business/hessian/feelingParkService] DEBUG org.mybatis.spring.SqlSessionUtils:28 - Creating SqlSession with JDBC Connection [jdbc:mysql://rm-wz9l1aamp2g509lkjo.mysql.rds.aliyuncs.com/cloud_syt?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true, UserName=jpark_syt@113.105.120.98, MySQL Connector Java]
 2019-03-26 11:25:44,533 [http-bio-8082-exec-3] [20190326112533b882074a31ca41bcbd6b497e4955ab88-0 - /jpark-business/hessian/feelingParkService] DEBUG java.sql.Connection:28 - ooo Connection Opened
 2019-03-26 11:25:44,595 [http-bio-8082-exec-3] [20190326112533b882074a31ca41bcbd6b497e4955ab88-0 - /jpark-business/hessian/feelingParkService] DEBUG org.mybatis.spring.transaction.SpringManagedTransaction:28 - JDBC Connection [jdbc:mysql://rm-wz9l1aamp2g509lkjo.mysql.rds.aliyuncs.com/cloud_syt?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true, UserName=jpark_syt@113.105.120.98, MySQL Connector Java] will not be managed by Spring
 2019-03-26 11:25:44,618 [http-bio-8082-exec-3] [20190326112533b882074a31ca41bcbd6b497e4955ab88-0 - /jpark-business/hessian/feelingParkService] DEBUG org.mybatis.spring.SqlSessionUtils:28 - SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5684e7d8] was not registered for synchronization because synchronization is not active
 2019-03-26 11:25:45,159 [http-bio-8082-exec-3] [20190326112533b882074a31ca41bcbd6b497e4955ab88-0 - /jpark-business/hessian/feelingParkService] DEBUG java.sql.PreparedStatement:28 - ==>  Executing: insert into t_no_isv_park(ID, PARK_NAME, PARK_CODE) values(?, ?, ?) 
 2019-03-26 11:25:45,161 [http-bio-8082-exec-3] [20190326112533b882074a31ca41bcbd6b497e4955ab88-0 - /jpark-business/hessian/feelingParkService] DEBUG java.sql.PreparedStatement:28 - ==> Parameters: 54a8693c16ab41f9bb6c485b87a81d82(String), 13135(String), AOPTEST4(String)
 2019-03-26 11:25:45,179 [http-bio-8082-exec-3] [20190326112533b882074a31ca41bcbd6b497e4955ab88-0 - /jpark-business/hessian/feelingParkService] DEBUG org.mybatis.spring.SqlSessionUtils:28 - Closing no transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5684e7d8]