09:41:37,848 [main] INFO jdbc.connection - 3. Connection opened org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
09:41:37,849 [main] DEBUG jdbc.connection - open connections: 3 (1)
09:41:37,849 [main] DEBUG jdbc.audit - 3. Connection.new Connection returned org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
09:41:37,849 [main] DEBUG jdbc.audit - 3. Connection.getAutoCommit() returned true org.mybatis.spring.transaction.SpringManagedTransaction.openConnection(SpringManagedTransaction.java:85)
09:41:37,849 [main] DEBUG org.mybatis.spring.transaction.SpringManagedTransaction - JDBC Connection [net.sf.log4jdbc.ConnectionSpy@20576557] will not be managed by Spring
切入点配置不正确时:
当你的切入点路径配置不正确时(或者你配置的路径与你调用的点不匹配时候)!那么这个切面(spring事物管理器)就不被执行,相应的就不会开启事物等等操作了。而数据源的连接默认是开启自动提交的,就达不到事物了。
当你配置正确后,信息是这样的:
09:53:54,254 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'empServiceImpl'
09:53:54,257 [main] DEBUG org.springframework.jdbc.datasource.DataSourceTransactionManager - Creating new transaction with name [com.boat.service.impl.EmpServiceImpl.updateEmpBaseInfo]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
09:53:54,257 [main] INFO jdbc.connection - 3. Connection opened org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
09:53:54,257 [main] DEBUG jdbc.connection - open connections: 3 (1)
09:53:54,257 [main] DEBUG jdbc.audit - 3. Connection.new Connection returned org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
09:53:54,258 [main] DEBUG org.springframework.jdbc.datasource.DataSourceTransactionManager - Acquired Connection [net.sf.log4jdbc.ConnectionSpy@360bc645] for JDBC transaction
09:53:54,258 [main] DEBUG jdbc.audit - 3. Connection.getAutoCommit() returned true org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:220)
09:53:54,258 [main] DEBUG org.springframework.jdbc.datasource.DataSourceTransactionManager - Switching JDBC Connection [net.sf.log4jdbc.ConnectionSpy@360bc645] to manual commit
09:53:54,259 [main] DEBUG jdbc.audit - 3. Connection.setAutoCommit(false) returned org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:225)
09:53:54,260 [main] DEBUG org.springframework.jdbc.datasource.DataSourceTransactionManager - Participating in existing transaction
09:53:54,277 [main] DEBUG org.mybatis.spring.SqlSessionUtils - Creating a new SqlSession
09:53:54,287 [main] DEBUG org.mybatis.spring.SqlSessionUtils - Registering transaction synchronization for SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1c7f96b1]
09:53:54,379 [main] DEBUG jdbc.audit - 3. Connection.getAutoCommit() returned false org.mybatis.spring.transaction.SpringManagedTransaction.openConnection(SpringManagedTransaction.java:85)
09:53:54,379 [main] DEBUG org.mybatis.spring.transaction.SpringManagedTransaction - JDBC Connection [net.sf.log4jdbc.ConnectionSpy@360bc645] will be managed by Spring
事物管理器在判断连接是否自动提交后,会将自动提交改为收到提交。并设置事物传播属性及隔离级别等等操作。这在事物管理这个切面处所在的事情。
09:41:37,849 [main] DEBUG jdbc.connection - open connections: 3 (1)
09:41:37,849 [main] DEBUG jdbc.audit - 3. Connection.new Connection returned org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
09:41:37,849 [main] DEBUG jdbc.audit - 3. Connection.getAutoCommit() returned true org.mybatis.spring.transaction.SpringManagedTransaction.openConnection(SpringManagedTransaction.java:85)
09:41:37,849 [main] DEBUG org.mybatis.spring.transaction.SpringManagedTransaction - JDBC Connection [net.sf.log4jdbc.ConnectionSpy@20576557] will not be managed by Spring
切入点配置不正确时:
当你的切入点路径配置不正确时(或者你配置的路径与你调用的点不匹配时候)!那么这个切面(spring事物管理器)就不被执行,相应的就不会开启事物等等操作了。而数据源的连接默认是开启自动提交的,就达不到事物了。
当你配置正确后,信息是这样的:
09:53:54,254 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'empServiceImpl'
09:53:54,257 [main] DEBUG org.springframework.jdbc.datasource.DataSourceTransactionManager - Creating new transaction with name [com.boat.service.impl.EmpServiceImpl.updateEmpBaseInfo]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
09:53:54,257 [main] INFO jdbc.connection - 3. Connection opened org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
09:53:54,257 [main] DEBUG jdbc.connection - open connections: 3 (1)
09:53:54,257 [main] DEBUG jdbc.audit - 3. Connection.new Connection returned org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
09:53:54,258 [main] DEBUG org.springframework.jdbc.datasource.DataSourceTransactionManager - Acquired Connection [net.sf.log4jdbc.ConnectionSpy@360bc645] for JDBC transaction
09:53:54,258 [main] DEBUG jdbc.audit - 3. Connection.getAutoCommit() returned true org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:220)
09:53:54,258 [main] DEBUG org.springframework.jdbc.datasource.DataSourceTransactionManager - Switching JDBC Connection [net.sf.log4jdbc.ConnectionSpy@360bc645] to manual commit
09:53:54,259 [main] DEBUG jdbc.audit - 3. Connection.setAutoCommit(false) returned org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:225)
09:53:54,260 [main] DEBUG org.springframework.jdbc.datasource.DataSourceTransactionManager - Participating in existing transaction
09:53:54,277 [main] DEBUG org.mybatis.spring.SqlSessionUtils - Creating a new SqlSession
09:53:54,287 [main] DEBUG org.mybatis.spring.SqlSessionUtils - Registering transaction synchronization for SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1c7f96b1]
09:53:54,379 [main] DEBUG jdbc.audit - 3. Connection.getAutoCommit() returned false org.mybatis.spring.transaction.SpringManagedTransaction.openConnection(SpringManagedTransaction.java:85)
09:53:54,379 [main] DEBUG org.mybatis.spring.transaction.SpringManagedTransaction - JDBC Connection [net.sf.log4jdbc.ConnectionSpy@360bc645] will be managed by Spring
事物管理器在判断连接是否自动提交后,会将自动提交改为收到提交。并设置事物传播属性及隔离级别等等操作。这在事物管理这个切面处所在的事情。