SpringBoot多数据源切换 多数据源事务解决方案 二

https://zhuanlan.zhihu.com/p/612825647?utm_id=0
https://blog.csdn.net/guzhangyu12345/article/details/108559810

SpringBoot多数据源事务解决方案
https://blog.csdn.net/u013407099/article/details/124526396多数据源切换下保证事务解决方案
https://blog.csdn.net/reee112/article/details/90442542

概述

在大型项目开发中,当数据量达到一定程度后,我们一般采用分库分表来实现数据层的拓展,面对复杂的存储层,相应的数据库中间件和多数据源切换的需求就应运而生。
这里我们重点讨论下多数据源切换,多数据源的动态切换可以方便我们快速的实现主从读写分离、异构纯粹多库等动态数据库操作。
常见的多数据源一般有以下两种解决方案:
1、通过显示模式声明多数据源,应用切换。优点是简单,缺点是不易于拓展,强耦合。
2、通过优先代理类实现动态切换,Spring的AbstractRoutingDataSource就是采用这种架构。
可以基于dynamic-datasource-spring-boot-starter实现动态多数据源切换。

前情提要

多数据源切换流程结构图如下所示,包含几个组成元素:

自定义的数据源配置处理,通过DataSource对象动态注册到系统中
自定义数据源标识注解与切面
数据源切换时的上下文线程变量持有者
自定义AbstractRoutingDataSource,实现数据源路由切换

事务

如果只是重写了AbstractRoutingDataSource方法,那么在事务下数据源是切换不了的,还需要重写事务方法。

Spring使用事务的方式有两种,一种是声明式事务,一种是编程式事务,我们讨论的都是关于声明式事务,这种方式很方便,也是大家常用的,这里为什么讨论这个问题,当我们想将不同库的表放在同一个事务使用的时候会报错。
我们要做就是动态的根据DataSourceType获取不同的Connection,不从缓存中获取Connection。

在Spring事务管理中有一个核心类DataSourceTransactionManager,该类是Spring事务核心的默认实现,AbstractPlatformTransactionManager是整体的Spring事务实现模板类,整体的继承结构如下图。

在这里插入图片描述

Mybatis

@DataSourceCurrent("master")
@Mapper
public interface Order1Mapper extends BaseMapper<Order1> {}@DataSourceCurrent("second")
@Mapper
public interface Order2Mapper extends BaseMapper<Order2> {}

公共方法标记@Transactional

@Service
public class OrderServiceImpl implements OrderService {@Resourceprivate Order1Service order1Service;@Resourceprivate Order2Service order2Service;@Transactional@Overridepublic void saveOrders2(){order1Service.updateOrderById();order2Service.updateOrderById(); //set exception, rollback all}

Main方法 @Import

@Import(DynamicDataSourceRegistrar.class)
@SpringBootApplication
public class DataSourceApplication22 {public static void main(String[] args) { SpringApplication.run(DataSourceApplication22.class, args); }
}

执行结果,回滚日志

D:\Java\jdk1.8.0_251\bin\java.exe -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true "-javaagent:D:\Program Files\JetBrains\IntelliJ IDEA 2020.1.1\lib\idea_rt.jar=51331:D:\Program Files\JetBrains\IntelliJ IDEA 2020.1.1\bin" -Dfile.encoding=UTF-8 -classpath D:\Java\jdk1.8.0_251\jre\lib\charsets.jar;D:\Java\jdk1.8.0_251\jre\lib\deploy.jar;D:\Java\jdk1.8.0_251\jre\lib\ext\access-bridge-64.jar;D:\Java\jdk1.8.0_251\jre\lib\ext\cldrdata.jar;D:\Java\jdk1.8.0_251\jre\lib\ext\dnsns.jar;D:\Java\jdk1.8.0_251\jre\lib\ext\jaccess.jar;D:\Java\jdk1.8.0_251\jre\lib\ext\jfxrt.jar;D:\Java\jdk1.8.0_251\jre\lib\ext\localedata.jar;D:\Java\jdk1.8.0_251\jre\lib\ext\nashorn.jar;D:\Java\jdk1.8.0_251\jre\lib\ext\sunec.jar;D:\Java\jdk1.8.0_251\jre\lib\ext\sunjce_provider.jar;D:\Java\jdk1.8.0_251\jre\lib\ext\sunmscapi.jar;D:\Java\jdk1.8.0_251\jre\lib\ext\sunpkcs11.jar;D:\Java\jdk1.8.0_251\jre\lib\ext\zipfs.jar;D:\Java\jdk1.8.0_251\jre\lib\javaws.jar;D:\Java\jdk1.8.0_251\jre\lib\jce.jar;D:\Java\jdk1.8.0_251\jre\lib\jfr.jar;D:\Java\jdk1.8.0_251\jre\lib\jfxswt.jar;D:\Java\jdk1.8.0_251\jre\lib\jsse.jar;D:\Java\jdk1.8.0_251\jre\lib\management-agent.jar;D:\Java\jdk1.8.0_251\jre\lib\plugin.jar;D:\Java\jdk1.8.0_251\jre\lib\resources.jar;D:\Java\jdk1.8.0_251\jre\lib\rt.jar;D:\IdeaProjects\test-datasource22\target\classes;C:\Users\LENOVO\.m2\repository\org\springframework\boot\spring-boot-starter-web\2.6.3\spring-boot-starter-web-2.6.3.jar;C:\Users\LENOVO\.m2\repository\org\springframework\boot\spring-boot-starter\2.6.3\spring-boot-starter-2.6.3.jar;C:\Users\LENOVO\.m2\repository\org\springframework\boot\spring-boot\2.6.3\spring-boot-2.6.3.jar;C:\Users\LENOVO\.m2\repository\org\springframework\boot\spring-boot-starter-logging\2.6.3\spring-boot-starter-logging-2.6.3.jar;C:\Users\LENOVO\.m2\repository\ch\qos\logback\logback-classic\1.2.10\logback-classic-1.2.10.jar;C:\Users\LENOVO\.m2\repository\ch\qos\logback\logback-core\1.2.10\logback-core-1.2.10.jar;C:\Users\LENOVO\.m2\repository\org\apache\logging\log4j\log4j-to-slf4j\2.17.1\log4j-to-slf4j-2.17.1.jar;C:\Users\LENOVO\.m2\repository\org\apache\logging\log4j\log4j-api\2.17.1\log4j-api-2.17.1.jar;C:\Users\LENOVO\.m2\repository\org\slf4j\jul-to-slf4j\1.7.33\jul-to-slf4j-1.7.33.jar;C:\Users\LENOVO\.m2\repository\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;C:\Users\LENOVO\.m2\repository\org\springframework\spring-core\5.3.15\spring-core-5.3.15.jar;C:\Users\LENOVO\.m2\repository\org\springframework\spring-jcl\5.3.15\spring-jcl-5.3.15.jar;C:\Users\LENOVO\.m2\repository\org\yaml\snakeyaml\1.29\snakeyaml-1.29.jar;C:\Users\LENOVO\.m2\repository\org\springframework\boot\spring-boot-starter-json\2.6.3\spring-boot-starter-json-2.6.3.jar;C:\Users\LENOVO\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.13.1\jackson-databind-2.13.1.jar;C:\Users\LENOVO\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.13.1\jackson-annotations-2.13.1.jar;C:\Users\LENOVO\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.13.1\jackson-core-2.13.1.jar;C:\Users\LENOVO\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.13.1\jackson-datatype-jdk8-2.13.1.jar;C:\Users\LENOVO\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.13.1\jackson-datatype-jsr310-2.13.1.jar;C:\Users\LENOVO\.m2\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.13.1\jackson-module-parameter-names-2.13.1.jar;C:\Users\LENOVO\.m2\repository\org\springframework\boot\spring-boot-starter-tomcat\2.6.3\spring-boot-starter-tomcat-2.6.3.jar;C:\Users\LENOVO\.m2\repository\org\apache\tomcat\embed\tomcat-embed-core\9.0.56\tomcat-embed-core-9.0.56.jar;C:\Users\LENOVO\.m2\repository\org\apache\tomcat\embed\tomcat-embed-el\9.0.56\tomcat-embed-el-9.0.56.jar;C:\Users\LENOVO\.m2\repository\org\apache\tomcat\embed\tomcat-embed-websocket\9.0.56\tomcat-embed-websocket-9.0.56.jar;C:\Users\LENOVO\.m2\repository\org\springframework\spring-web\5.3.15\spring-web-5.3.15.jar;C:\Users\LENOVO\.m2\repository\org\springframework\spring-beans\5.3.15\spring-beans-5.3.15.jar;C:\Users\LENOVO\.m2\repository\org\springframework\spring-webmvc\5.3.15\spring-webmvc-5.3.15.jar;C:\Users\LENOVO\.m2\repository\org\springframework\spring-context\5.3.15\spring-context-5.3.15.jar;C:\Users\LENOVO\.m2\repository\org\springframework\spring-expression\5.3.15\spring-expression-5.3.15.jar;C:\Users\LENOVO\.m2\repository\org\springframework\boot\spring-boot-starter-aop\2.6.3\spring-boot-starter-aop-2.6.3.jar;C:\Users\LENOVO\.m2\repository\org\springframework\spring-aop\5.3.15\spring-aop-5.3.15.jar;C:\Users\LENOVO\.m2\repository\org\aspectj\aspectjweaver\1.9.7\aspectjweaver-1.9.7.jar;C:\Users\LENOVO\.m2\repository\com\baomidou\mybatis-plus-boot-starter\3.3.2\mybatis-plus-boot-starter-3.3.2.jar;C:\Users\LENOVO\.m2\repository\com\baomidou\mybatis-plus\3.3.2\mybatis-plus-3.3.2.jar;C:\Users\LENOVO\.m2\repository\com\baomidou\mybatis-plus-extension\3.3.2\mybatis-plus-extension-3.3.2.jar;C:\Users\LENOVO\.m2\repository\com\baomidou\mybatis-plus-core\3.3.2\mybatis-plus-core-3.3.2.jar;C:\Users\LENOVO\.m2\repository\com\baomidou\mybatis-plus-annotation\3.3.2\mybatis-plus-annotation-3.3.2.jar;C:\Users\LENOVO\.m2\repository\com\github\jsqlparser\jsqlparser\3.1\jsqlparser-3.1.jar;C:\Users\LENOVO\.m2\repository\org\mybatis\mybatis\3.5.4\mybatis-3.5.4.jar;C:\Users\LENOVO\.m2\repository\org\mybatis\mybatis-spring\2.0.4\mybatis-spring-2.0.4.jar;C:\Users\LENOVO\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\2.6.3\spring-boot-autoconfigure-2.6.3.jar;C:\Users\LENOVO\.m2\repository\org\springframework\boot\spring-boot-starter-jdbc\2.6.3\spring-boot-starter-jdbc-2.6.3.jar;C:\Users\LENOVO\.m2\repository\com\zaxxer\HikariCP\4.0.3\HikariCP-4.0.3.jar;C:\Users\LENOVO\.m2\repository\org\slf4j\slf4j-api\1.7.33\slf4j-api-1.7.33.jar;C:\Users\LENOVO\.m2\repository\org\springframework\spring-jdbc\5.3.15\spring-jdbc-5.3.15.jar;C:\Users\LENOVO\.m2\repository\org\springframework\spring-tx\5.3.15\spring-tx-5.3.15.jar;C:\Users\LENOVO\.m2\repository\mysql\mysql-connector-java\8.0.28\mysql-connector-java-8.0.28.jar;C:\Users\LENOVO\.m2\repository\com\alibaba\fastjson\1.2.83\fastjson-1.2.83.jar;C:\Users\LENOVO\.m2\repository\org\projectlombok\lombok\1.18.22\lombok-1.18.22.jar com.java.DataSourceApplication22.   ____          _            __ _ _/\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \\\/  ___)| |_)| | | | | || (_| |  ) ) ) )'  |____| .__|_| |_|_| |_\__, | / / / /=========|_|==============|___/=/_/_/_/:: Spring Boot ::                (v2.6.3)2024-03-10 17:41:56.342  INFO 30476 --- [           main] com.java.DataSourceApplication22         : Starting DataSourceApplication22 using Java 1.8.0_251 on DESKTOP-GCE7E0L with PID 30476 (D:\IdeaProjects\test-datasource22\target\classes started by LENOVO in D:\IdeaProjects\test-datasource22)
2024-03-10 17:41:56.346  INFO 30476 --- [           main] com.java.DataSourceApplication22         : The following profiles are active: test
2024-03-10 17:41:56.759  INFO 30476 --- [           main] c.j.config.DynamicDataSourceRegistrar    : 开始注册数据源 evn
2024-03-10 17:41:57.236  INFO 30476 --- [           main] c.j.config.DynamicDataSourceRegistrar    : register, bind ds: master, second ---- registerBeanDefinitions()
2024-03-10 17:41:57.246  INFO 30476 --- [           main] com.zaxxer.hikari.HikariDataSource       : master - Starting...
2024-03-10 17:41:57.437  INFO 30476 --- [           main] com.zaxxer.hikari.HikariDataSource       : master - Start completed.
2024-03-10 17:41:57.442  INFO 30476 --- [           main] c.j.config.DynamicDataSourceRegistrar    : ==================注册数据源master成功
2024-03-10 17:41:57.442  INFO 30476 --- [           main] com.zaxxer.hikari.HikariDataSource       : second - Starting...
2024-03-10 17:41:57.454  INFO 30476 --- [           main] com.zaxxer.hikari.HikariDataSource       : second - Start completed.
2024-03-10 17:41:57.454  INFO 30476 --- [           main] c.j.config.DynamicDataSourceRegistrar    : ==========注册数据源second成功
2024-03-10 17:41:57.457  INFO 30476 --- [           main] c.j.config.DynamicDataSourceRegistrar    : 注册数据源成功,一共注册2个数据源
2024-03-10 17:41:58.781  INFO 30476 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8099 (http)
2024-03-10 17:41:58.792  INFO 30476 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2024-03-10 17:41:58.793  INFO 30476 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.56]
2024-03-10 17:41:58.951  INFO 30476 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2024-03-10 17:41:58.951  INFO 30476 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2522 ms
dynamic ds classpath:mapper/*.xml_ _   |_  _ _|_. ___ _ |    _ 
| | |\/|_)(_| | |_\  |_)||_|_\ /               |         3.3.2 
Logging initialized using 'class org.apache.ibatis.logging.stdout.StdOutImpl' adapter.
2024-03-10 17:42:01.556  INFO 30476 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8099 (http) with context path ''
2024-03-10 17:42:01.570  INFO 30476 --- [           main] com.java.DataSourceApplication22         : Started DataSourceApplication22 in 6.208 seconds (JVM running for 8.211)
2024-03-10 17:42:22.205  INFO 30476 --- [nio-8099-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2024-03-10 17:42:22.205  INFO 30476 --- [nio-8099-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2024-03-10 17:42:22.207  INFO 30476 --- [nio-8099-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 2 ms
2024-03-10 17:42:22.260  INFO 30476 --- [nio-8099-exec-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2024-03-10 17:42:22.272  INFO 30476 --- [nio-8099-exec-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2024-03-10 17:42:22.292  INFO 30476 --- [nio-8099-exec-1] com.java.service.OrderServiceImpl        : update start......
2024-03-10 17:42:22.308  INFO 30476 --- [nio-8099-exec-1] com.java.service.Order1ServiceImpl       : update order1 start... 
2024-03-10 17:42:22.320  INFO 30476 --- [nio-8099-exec-1] com.java.config.DsMapperAspect1          : MapperAspect set 数据源: master
2024-03-10 17:42:22.321  INFO 30476 --- [nio-8099-exec-1] com.java.config.DataSourceContextHolder  : context, set ds key:master
Creating a new SqlSession
================init MultiDataSourceTransaction Factory================
Registering transaction synchronization for SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2eaf1022]
2024-03-10 17:42:22.404  INFO 30476 --- [nio-8099-exec-1] com.java.config.DataSourceContextHolder  : context, get ds key:master
2024-03-10 17:42:22.405  INFO 30476 --- [nio-8099-exec-1] c.j.config.MultiDataSourceTransaction    : trans, getConn from ds map, dsName:master
2024-03-10 17:42:22.405  INFO 30476 --- [nio-8099-exec-1] com.java.config.DynamicDataSourceRt      : ds, get conn, ThreadLocal----null
2024-03-10 17:42:22.405 ERROR 30476 --- [nio-8099-exec-1] com.java.config.DynamicDataSourceRt      : ds get conn, ds key null, 没开事务
2024-03-10 17:42:22.405  INFO 30476 --- [nio-8099-exec-1] com.java.config.DataSourceContextHolder  : context, get ds key:master
2024-03-10 17:42:22.405  INFO 30476 --- [nio-8099-exec-1] com.java.config.DynamicDataSourceRt      : ds, determineCurrentLookupKey 当前数据源: master
2024-03-10 17:42:22.406  INFO 30476 --- [nio-8099-exec-1] c.j.config.MultiDataSourceTransaction    : trans, getConn from ds, conn: HikariProxyConnection@198635215 wrapping com.mysql.cj.jdbc.ConnectionImpl@49b6b5eb
Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2eaf1022]
2024-03-10 17:42:22.464  INFO 30476 --- [nio-8099-exec-1] com.java.config.DataSourceContextHolder  : context, rm key:master
2024-03-10 17:42:22.465  INFO 30476 --- [nio-8099-exec-1] com.java.service.Order1ServiceImpl       : ---update order1 OK, result:1
2024-03-10 17:42:22.466  INFO 30476 --- [nio-8099-exec-1] com.java.service.OrderServiceImpl        : ======================================
2024-03-10 17:42:22.479  INFO 30476 --- [nio-8099-exec-1] com.java.service.Order2ServiceImpl       : ---update order2 start...
2024-03-10 17:42:22.481  INFO 30476 --- [nio-8099-exec-1] com.java.config.DsMapperAspect1          : MapperAspect set 数据源: second
2024-03-10 17:42:22.481  INFO 30476 --- [nio-8099-exec-1] com.java.config.DataSourceContextHolder  : context, set ds key:second
Fetched SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2eaf1022] from current transaction
2024-03-10 17:42:22.483  INFO 30476 --- [nio-8099-exec-1] com.java.config.DataSourceContextHolder  : context, get ds key:second
2024-03-10 17:42:22.483  INFO 30476 --- [nio-8099-exec-1] c.j.config.MultiDataSourceTransaction    : trans, getConn from ds map, dsName:second
2024-03-10 17:42:22.483  INFO 30476 --- [nio-8099-exec-1] com.java.config.DynamicDataSourceRt      : ds, get conn, ThreadLocal----null
2024-03-10 17:42:22.483 ERROR 30476 --- [nio-8099-exec-1] com.java.config.DynamicDataSourceRt      : ds get conn, ds key null, 没开事务
2024-03-10 17:42:22.483  INFO 30476 --- [nio-8099-exec-1] com.java.config.DataSourceContextHolder  : context, get ds key:second
2024-03-10 17:42:22.483  INFO 30476 --- [nio-8099-exec-1] com.java.config.DynamicDataSourceRt      : ds, determineCurrentLookupKey 当前数据源: second
2024-03-10 17:42:22.484  INFO 30476 --- [nio-8099-exec-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-2 - Starting...
2024-03-10 17:42:22.493  INFO 30476 --- [nio-8099-exec-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-2 - Start completed.
2024-03-10 17:42:22.494  INFO 30476 --- [nio-8099-exec-1] c.j.config.MultiDataSourceTransaction    : trans, getConn from ds, conn: HikariProxyConnection@21529602 wrapping com.mysql.cj.jdbc.ConnectionImpl@16746d16
Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2eaf1022]
2024-03-10 17:42:22.499  INFO 30476 --- [nio-8099-exec-1] com.java.config.DataSourceContextHolder  : context, rm key:second
2024-03-10 17:42:22.500  INFO 30476 --- [nio-8099-exec-1] com.java.service.Order2ServiceImpl       : ---update order2 OK, result:1
Transaction synchronization deregistering SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2eaf1022]
Transaction synchronization closing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2eaf1022]
2024-03-10 17:42:22.502  INFO 30476 --- [nio-8099-exec-1] c.j.config.MultiDataSourceTransaction    : trans, do rollback
2024-03-10 17:42:22.515  INFO 30476 --- [nio-8099-exec-1] c.j.config.MultiDataSourceTransaction    : trans, do rollback
2024-03-10 17:42:22.520  INFO 30476 --- [nio-8099-exec-1] c.j.config.MultiDataSourceTransaction    : trans, connection close
2024-03-10 17:42:22.527  INFO 30476 --- [nio-8099-exec-1] c.j.config.MultiDataSourceTransaction    : trans, connection close
2024-03-10 17:42:22.555 ERROR 30476 --- [nio-8099-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.RuntimeException: order2 exception] with root causejava.lang.RuntimeException: order2 exceptionat com.java.service.Order2ServiceImpl.updateOrderById(Order2ServiceImpl.java:33) ~[classes/:na]at com.java.service.Order2ServiceImpl$$FastClassBySpringCGLIB$$31f65359.invoke(<generated>) ~[classes/:na]at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.3.15.jar:5.3.15]at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689) ~[spring-aop-5.3.15.jar:5.3.15]at com.java.service.Order2ServiceImpl$$EnhancerBySpringCGLIB$$abbb8a2e.updateOrderById(<generated>) ~[classes/:na]at com.java.service.OrderServiceImpl.saveOrders2(OrderServiceImpl.java:62) ~[classes/:na]at com.java.service.OrderServiceImpl$$FastClassBySpringCGLIB$$f72571f.invoke(<generated>) ~[classes/:na]at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.3.15.jar:5.3.15]at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:783) ~[spring-aop-5.3.15.jar:5.3.15]at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.3.15.jar:5.3.15]at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:753) ~[spring-aop-5.3.15.jar:5.3.15]at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123) ~[spring-tx-5.3.15.jar:5.3.15]at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388) ~[spring-tx-5.3.15.jar:5.3.15]at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119) ~[spring-tx-5.3.15.jar:5.3.15]at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.15.jar:5.3.15]at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:753) ~[spring-aop-5.3.15.jar:5.3.15]at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:698) ~[spring-aop-5.3.15.jar:5.3.15]at com.java.service.OrderServiceImpl$$EnhancerBySpringCGLIB$$8e952140.saveOrders2(<generated>) ~[classes/:na]at com.java.controller.OrderController.saveOrder2(OrderController.java:34) ~[classes/:na]at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_251]at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_251]at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_251]at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_251]at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-5.3.15.jar:5.3.15]at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150) ~[spring-web-5.3.15.jar:5.3.15]at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117) ~[spring-webmvc-5.3.15.jar:5.3.15]at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895) ~[spring-webmvc-5.3.15.jar:5.3.15]at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808) ~[spring-webmvc-5.3.15.jar:5.3.15]at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.3.15.jar:5.3.15]at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067) ~[spring-webmvc-5.3.15.jar:5.3.15]at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963) ~[spring-webmvc-5.3.15.jar:5.3.15]at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.3.15.jar:5.3.15]at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) ~[spring-webmvc-5.3.15.jar:5.3.15]at javax.servlet.http.HttpServlet.service(HttpServlet.java:681) ~[tomcat-embed-core-9.0.56.jar:4.0.FR]at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.3.15.jar:5.3.15]at javax.servlet.http.HttpServlet.service(HttpServlet.java:764) ~[tomcat-embed-core-9.0.56.jar:4.0.FR]at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227) ~[tomcat-embed-core-9.0.56.jar:9.0.56]at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.56.jar:9.0.56]at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.56.jar:9.0.56]at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.56.jar:9.0.56]at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.56.jar:9.0.56]at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.3.15.jar:5.3.15]at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.15.jar:5.3.15]at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.56.jar:9.0.56]at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.56.jar:9.0.56]at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.3.15.jar:5.3.15]at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.15.jar:5.3.15]at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.56.jar:9.0.56]at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.56.jar:9.0.56]at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.3.15.jar:5.3.15]at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.15.jar:5.3.15]at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.56.jar:9.0.56]at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.56.jar:9.0.56]at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197) ~[tomcat-embed-core-9.0.56.jar:9.0.56]at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) [tomcat-embed-core-9.0.56.jar:9.0.56]at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:540) [tomcat-embed-core-9.0.56.jar:9.0.56]at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135) [tomcat-embed-core-9.0.56.jar:9.0.56]at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) [tomcat-embed-core-9.0.56.jar:9.0.56]at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) [tomcat-embed-core-9.0.56.jar:9.0.56]at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357) [tomcat-embed-core-9.0.56.jar:9.0.56]at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:382) [tomcat-embed-core-9.0.56.jar:9.0.56]at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) [tomcat-embed-core-9.0.56.jar:9.0.56]at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:895) [tomcat-embed-core-9.0.56.jar:9.0.56]at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1732) [tomcat-embed-core-9.0.56.jar:9.0.56]at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.56.jar:9.0.56]at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) [tomcat-embed-core-9.0.56.jar:9.0.56]at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) [tomcat-embed-core-9.0.56.jar:9.0.56]at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.56.jar:9.0.56]at java.lang.Thread.run(Thread.java:748) [na:1.8.0_251]

执行成功日志

D:\Java\jdk1.8.0_251\bin\java.exe -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true "-javaagent:D:\Program Files\JetBrains\IntelliJ IDEA 2020.1.1\lib\idea_rt.jar=51430:D:\Program Files\JetBrains\IntelliJ IDEA 2020.1.1\bin" -Dfile.encoding=UTF-8 -classpath D:\Java\jdk1.8.0_251\jre\lib\charsets.jar;D:\Java\jdk1.8.0_251\jre\lib\deploy.jar;D:\Java\jdk1.8.0_251\jre\lib\ext\access-bridge-64.jar;D:\Java\jdk1.8.0_251\jre\lib\ext\cldrdata.jar;D:\Java\jdk1.8.0_251\jre\lib\ext\dnsns.jar;D:\Java\jdk1.8.0_251\jre\lib\ext\jaccess.jar;D:\Java\jdk1.8.0_251\jre\lib\ext\jfxrt.jar;D:\Java\jdk1.8.0_251\jre\lib\ext\localedata.jar;D:\Java\jdk1.8.0_251\jre\lib\ext\nashorn.jar;D:\Java\jdk1.8.0_251\jre\lib\ext\sunec.jar;D:\Java\jdk1.8.0_251\jre\lib\ext\sunjce_provider.jar;D:\Java\jdk1.8.0_251\jre\lib\ext\sunmscapi.jar;D:\Java\jdk1.8.0_251\jre\lib\ext\sunpkcs11.jar;D:\Java\jdk1.8.0_251\jre\lib\ext\zipfs.jar;D:\Java\jdk1.8.0_251\jre\lib\javaws.jar;D:\Java\jdk1.8.0_251\jre\lib\jce.jar;D:\Java\jdk1.8.0_251\jre\lib\jfr.jar;D:\Java\jdk1.8.0_251\jre\lib\jfxswt.jar;D:\Java\jdk1.8.0_251\jre\lib\jsse.jar;D:\Java\jdk1.8.0_251\jre\lib\management-agent.jar;D:\Java\jdk1.8.0_251\jre\lib\plugin.jar;D:\Java\jdk1.8.0_251\jre\lib\resources.jar;D:\Java\jdk1.8.0_251\jre\lib\rt.jar;D:\IdeaProjects\test-datasource22\target\classes;C:\Users\LENOVO\.m2\repository\org\springframework\boot\spring-boot-starter-web\2.6.3\spring-boot-starter-web-2.6.3.jar;C:\Users\LENOVO\.m2\repository\org\springframework\boot\spring-boot-starter\2.6.3\spring-boot-starter-2.6.3.jar;C:\Users\LENOVO\.m2\repository\org\springframework\boot\spring-boot\2.6.3\spring-boot-2.6.3.jar;C:\Users\LENOVO\.m2\repository\org\springframework\boot\spring-boot-starter-logging\2.6.3\spring-boot-starter-logging-2.6.3.jar;C:\Users\LENOVO\.m2\repository\ch\qos\logback\logback-classic\1.2.10\logback-classic-1.2.10.jar;C:\Users\LENOVO\.m2\repository\ch\qos\logback\logback-core\1.2.10\logback-core-1.2.10.jar;C:\Users\LENOVO\.m2\repository\org\apache\logging\log4j\log4j-to-slf4j\2.17.1\log4j-to-slf4j-2.17.1.jar;C:\Users\LENOVO\.m2\repository\org\apache\logging\log4j\log4j-api\2.17.1\log4j-api-2.17.1.jar;C:\Users\LENOVO\.m2\repository\org\slf4j\jul-to-slf4j\1.7.33\jul-to-slf4j-1.7.33.jar;C:\Users\LENOVO\.m2\repository\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;C:\Users\LENOVO\.m2\repository\org\springframework\spring-core\5.3.15\spring-core-5.3.15.jar;C:\Users\LENOVO\.m2\repository\org\springframework\spring-jcl\5.3.15\spring-jcl-5.3.15.jar;C:\Users\LENOVO\.m2\repository\org\yaml\snakeyaml\1.29\snakeyaml-1.29.jar;C:\Users\LENOVO\.m2\repository\org\springframework\boot\spring-boot-starter-json\2.6.3\spring-boot-starter-json-2.6.3.jar;C:\Users\LENOVO\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.13.1\jackson-databind-2.13.1.jar;C:\Users\LENOVO\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.13.1\jackson-annotations-2.13.1.jar;C:\Users\LENOVO\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.13.1\jackson-core-2.13.1.jar;C:\Users\LENOVO\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.13.1\jackson-datatype-jdk8-2.13.1.jar;C:\Users\LENOVO\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.13.1\jackson-datatype-jsr310-2.13.1.jar;C:\Users\LENOVO\.m2\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.13.1\jackson-module-parameter-names-2.13.1.jar;C:\Users\LENOVO\.m2\repository\org\springframework\boot\spring-boot-starter-tomcat\2.6.3\spring-boot-starter-tomcat-2.6.3.jar;C:\Users\LENOVO\.m2\repository\org\apache\tomcat\embed\tomcat-embed-core\9.0.56\tomcat-embed-core-9.0.56.jar;C:\Users\LENOVO\.m2\repository\org\apache\tomcat\embed\tomcat-embed-el\9.0.56\tomcat-embed-el-9.0.56.jar;C:\Users\LENOVO\.m2\repository\org\apache\tomcat\embed\tomcat-embed-websocket\9.0.56\tomcat-embed-websocket-9.0.56.jar;C:\Users\LENOVO\.m2\repository\org\springframework\spring-web\5.3.15\spring-web-5.3.15.jar;C:\Users\LENOVO\.m2\repository\org\springframework\spring-beans\5.3.15\spring-beans-5.3.15.jar;C:\Users\LENOVO\.m2\repository\org\springframework\spring-webmvc\5.3.15\spring-webmvc-5.3.15.jar;C:\Users\LENOVO\.m2\repository\org\springframework\spring-context\5.3.15\spring-context-5.3.15.jar;C:\Users\LENOVO\.m2\repository\org\springframework\spring-expression\5.3.15\spring-expression-5.3.15.jar;C:\Users\LENOVO\.m2\repository\org\springframework\boot\spring-boot-starter-aop\2.6.3\spring-boot-starter-aop-2.6.3.jar;C:\Users\LENOVO\.m2\repository\org\springframework\spring-aop\5.3.15\spring-aop-5.3.15.jar;C:\Users\LENOVO\.m2\repository\org\aspectj\aspectjweaver\1.9.7\aspectjweaver-1.9.7.jar;C:\Users\LENOVO\.m2\repository\com\baomidou\mybatis-plus-boot-starter\3.3.2\mybatis-plus-boot-starter-3.3.2.jar;C:\Users\LENOVO\.m2\repository\com\baomidou\mybatis-plus\3.3.2\mybatis-plus-3.3.2.jar;C:\Users\LENOVO\.m2\repository\com\baomidou\mybatis-plus-extension\3.3.2\mybatis-plus-extension-3.3.2.jar;C:\Users\LENOVO\.m2\repository\com\baomidou\mybatis-plus-core\3.3.2\mybatis-plus-core-3.3.2.jar;C:\Users\LENOVO\.m2\repository\com\baomidou\mybatis-plus-annotation\3.3.2\mybatis-plus-annotation-3.3.2.jar;C:\Users\LENOVO\.m2\repository\com\github\jsqlparser\jsqlparser\3.1\jsqlparser-3.1.jar;C:\Users\LENOVO\.m2\repository\org\mybatis\mybatis\3.5.4\mybatis-3.5.4.jar;C:\Users\LENOVO\.m2\repository\org\mybatis\mybatis-spring\2.0.4\mybatis-spring-2.0.4.jar;C:\Users\LENOVO\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\2.6.3\spring-boot-autoconfigure-2.6.3.jar;C:\Users\LENOVO\.m2\repository\org\springframework\boot\spring-boot-starter-jdbc\2.6.3\spring-boot-starter-jdbc-2.6.3.jar;C:\Users\LENOVO\.m2\repository\com\zaxxer\HikariCP\4.0.3\HikariCP-4.0.3.jar;C:\Users\LENOVO\.m2\repository\org\slf4j\slf4j-api\1.7.33\slf4j-api-1.7.33.jar;C:\Users\LENOVO\.m2\repository\org\springframework\spring-jdbc\5.3.15\spring-jdbc-5.3.15.jar;C:\Users\LENOVO\.m2\repository\org\springframework\spring-tx\5.3.15\spring-tx-5.3.15.jar;C:\Users\LENOVO\.m2\repository\mysql\mysql-connector-java\8.0.28\mysql-connector-java-8.0.28.jar;C:\Users\LENOVO\.m2\repository\com\alibaba\fastjson\1.2.83\fastjson-1.2.83.jar;C:\Users\LENOVO\.m2\repository\org\projectlombok\lombok\1.18.22\lombok-1.18.22.jar com.java.DataSourceApplication22.   ____          _            __ _ _/\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \\\/  ___)| |_)| | | | | || (_| |  ) ) ) )'  |____| .__|_| |_|_| |_\__, | / / / /=========|_|==============|___/=/_/_/_/:: Spring Boot ::                (v2.6.3)2024-03-10 17:42:54.409  INFO 21316 --- [           main] com.java.DataSourceApplication22         : Starting DataSourceApplication22 using Java 1.8.0_251 on DESKTOP-GCE7E0L with PID 21316 (D:\IdeaProjects\test-datasource22\target\classes started by LENOVO in D:\IdeaProjects\test-datasource22)
2024-03-10 17:42:54.416  INFO 21316 --- [           main] com.java.DataSourceApplication22         : The following profiles are active: test
2024-03-10 17:42:55.127  INFO 21316 --- [           main] c.j.config.DynamicDataSourceRegistrar    : 开始注册数据源 evn
2024-03-10 17:42:56.095  INFO 21316 --- [           main] c.j.config.DynamicDataSourceRegistrar    : register, bind ds: master, second ---- registerBeanDefinitions()
2024-03-10 17:42:56.109  INFO 21316 --- [           main] com.zaxxer.hikari.HikariDataSource       : master - Starting...
2024-03-10 17:42:56.512  INFO 21316 --- [           main] com.zaxxer.hikari.HikariDataSource       : master - Start completed.
2024-03-10 17:42:56.518  INFO 21316 --- [           main] c.j.config.DynamicDataSourceRegistrar    : ==================注册数据源master成功
2024-03-10 17:42:56.519  INFO 21316 --- [           main] com.zaxxer.hikari.HikariDataSource       : second - Starting...
2024-03-10 17:42:56.538  INFO 21316 --- [           main] com.zaxxer.hikari.HikariDataSource       : second - Start completed.
2024-03-10 17:42:56.538  INFO 21316 --- [           main] c.j.config.DynamicDataSourceRegistrar    : ==========注册数据源second成功
2024-03-10 17:42:56.543  INFO 21316 --- [           main] c.j.config.DynamicDataSourceRegistrar    : 注册数据源成功,一共注册2个数据源
2024-03-10 17:42:58.425  INFO 21316 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8099 (http)
2024-03-10 17:42:58.445  INFO 21316 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2024-03-10 17:42:58.446  INFO 21316 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.56]
2024-03-10 17:42:58.664  INFO 21316 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2024-03-10 17:42:58.664  INFO 21316 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 4109 ms
dynamic ds classpath:mapper/*.xml_ _   |_  _ _|_. ___ _ |    _ 
| | |\/|_)(_| | |_\  |_)||_|_\ /               |         3.3.2 
Logging initialized using 'class org.apache.ibatis.logging.stdout.StdOutImpl' adapter.
2024-03-10 17:43:01.646  INFO 21316 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8099 (http) with context path ''
2024-03-10 17:43:01.666  INFO 21316 --- [           main] com.java.DataSourceApplication22         : Started DataSourceApplication22 in 8.584 seconds (JVM running for 11.011)
2024-03-10 17:45:11.727  INFO 21316 --- [nio-8099-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2024-03-10 17:45:11.727  INFO 21316 --- [nio-8099-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2024-03-10 17:45:11.730  INFO 21316 --- [nio-8099-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 2 ms
2024-03-10 17:45:11.781  INFO 21316 --- [nio-8099-exec-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2024-03-10 17:45:11.789  INFO 21316 --- [nio-8099-exec-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2024-03-10 17:45:11.805  INFO 21316 --- [nio-8099-exec-1] com.java.service.OrderServiceImpl        : update start......
2024-03-10 17:45:11.820  INFO 21316 --- [nio-8099-exec-1] com.java.service.Order1ServiceImpl       : update order1 start... 
2024-03-10 17:45:11.831  INFO 21316 --- [nio-8099-exec-1] com.java.config.DsMapperAspect1          : MapperAspect set 数据源: master
2024-03-10 17:45:11.833  INFO 21316 --- [nio-8099-exec-1] com.java.config.DataSourceContextHolder  : context, set ds key:master
Creating a new SqlSession
================init MultiDataSourceTransaction Factory================
Registering transaction synchronization for SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@28025c1f]
2024-03-10 17:45:11.905  INFO 21316 --- [nio-8099-exec-1] com.java.config.DataSourceContextHolder  : context, get ds key:master
2024-03-10 17:45:11.905  INFO 21316 --- [nio-8099-exec-1] c.j.config.MultiDataSourceTransaction    : trans, getConn from ds map, dsName:master
2024-03-10 17:45:11.905  INFO 21316 --- [nio-8099-exec-1] com.java.config.DynamicDataSourceRt      : ds, get conn, ThreadLocal----null
2024-03-10 17:45:11.905 ERROR 21316 --- [nio-8099-exec-1] com.java.config.DynamicDataSourceRt      : ds get conn, ds key null, 没开事务
2024-03-10 17:45:11.906  INFO 21316 --- [nio-8099-exec-1] com.java.config.DataSourceContextHolder  : context, get ds key:master
2024-03-10 17:45:11.906  INFO 21316 --- [nio-8099-exec-1] com.java.config.DynamicDataSourceRt      : ds, determineCurrentLookupKey 当前数据源: master
2024-03-10 17:45:11.906  INFO 21316 --- [nio-8099-exec-1] c.j.config.MultiDataSourceTransaction    : trans, getConn from ds, conn: HikariProxyConnection@1000277724 wrapping com.mysql.cj.jdbc.ConnectionImpl@4bc1686c
Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@28025c1f]
2024-03-10 17:45:11.963  INFO 21316 --- [nio-8099-exec-1] com.java.config.DataSourceContextHolder  : context, rm key:master
2024-03-10 17:45:11.963  INFO 21316 --- [nio-8099-exec-1] com.java.service.Order1ServiceImpl       : ---update order1 OK, result:1
2024-03-10 17:45:11.963  INFO 21316 --- [nio-8099-exec-1] com.java.service.OrderServiceImpl        : ======================================
2024-03-10 17:45:11.977  INFO 21316 --- [nio-8099-exec-1] com.java.service.Order2ServiceImpl       : ---update order2 start...
2024-03-10 17:45:11.978  INFO 21316 --- [nio-8099-exec-1] com.java.config.DsMapperAspect1          : MapperAspect set 数据源: second
2024-03-10 17:45:11.978  INFO 21316 --- [nio-8099-exec-1] com.java.config.DataSourceContextHolder  : context, set ds key:second
Fetched SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@28025c1f] from current transaction
2024-03-10 17:45:11.980  INFO 21316 --- [nio-8099-exec-1] com.java.config.DataSourceContextHolder  : context, get ds key:second
2024-03-10 17:45:11.980  INFO 21316 --- [nio-8099-exec-1] c.j.config.MultiDataSourceTransaction    : trans, getConn from ds map, dsName:second
2024-03-10 17:45:11.980  INFO 21316 --- [nio-8099-exec-1] com.java.config.DynamicDataSourceRt      : ds, get conn, ThreadLocal----null
2024-03-10 17:45:11.980 ERROR 21316 --- [nio-8099-exec-1] com.java.config.DynamicDataSourceRt      : ds get conn, ds key null, 没开事务
2024-03-10 17:45:11.980  INFO 21316 --- [nio-8099-exec-1] com.java.config.DataSourceContextHolder  : context, get ds key:second
2024-03-10 17:45:11.980  INFO 21316 --- [nio-8099-exec-1] com.java.config.DynamicDataSourceRt      : ds, determineCurrentLookupKey 当前数据源: second
2024-03-10 17:45:11.980  INFO 21316 --- [nio-8099-exec-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-2 - Starting...
2024-03-10 17:45:11.995  INFO 21316 --- [nio-8099-exec-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-2 - Start completed.
2024-03-10 17:45:11.995  INFO 21316 --- [nio-8099-exec-1] c.j.config.MultiDataSourceTransaction    : trans, getConn from ds, conn: HikariProxyConnection@2121567456 wrapping com.mysql.cj.jdbc.ConnectionImpl@76efda58
Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@28025c1f]
2024-03-10 17:45:11.999  INFO 21316 --- [nio-8099-exec-1] com.java.config.DataSourceContextHolder  : context, rm key:second
2024-03-10 17:45:12.000  INFO 21316 --- [nio-8099-exec-1] com.java.service.Order2ServiceImpl       : ---update order2 OK, result:1
2024-03-10 17:45:12.000  INFO 21316 --- [nio-8099-exec-1] com.java.service.OrderServiceImpl        : update order1 order2, END......
Transaction synchronization committing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@28025c1f]
2024-03-10 17:45:12.001  INFO 21316 --- [nio-8099-exec-1] c.j.config.MultiDataSourceTransaction    : trans, commit ----- autoCommit: false
2024-03-10 17:45:12.004  INFO 21316 --- [nio-8099-exec-1] c.j.config.MultiDataSourceTransaction    : trans, commit ----- autoCommit: false
Transaction synchronization deregistering SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@28025c1f]
Transaction synchronization closing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@28025c1f]
2024-03-10 17:45:12.012  INFO 21316 --- [nio-8099-exec-1] c.j.config.MultiDataSourceTransaction    : trans, connection close
2024-03-10 17:45:12.020  INFO 21316 --- [nio-8099-exec-1] c.j.config.MultiDataSourceTransaction    : trans, connection close

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/740104.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

郑州大学2024年3月acm实验室招新赛题解(A-L)

这里感谢一下计算机学术交流协会会长&#xff0c;acm实验室的中坚成员&#xff0c;以及本次比赛的出题人之一孙昱涵将他的账号借给了我。 回顾一下的话&#xff0c;这场的难度其实不是很大&#xff0c;不过对招新的新手来说难度还是挺大的。去掉签到都没签出来的选手的话&…

【C++ Primer Plus学习记录】第6章复习题

1.请看下面两个计算空格和换行符数目的代码片段&#xff1a; //Version 1 while(cin.get(ch)) //quit on eof,EOF(检测文件尾) { if(ch )spaces;if(ch \n)newlines; }//Version 2 while(cin.get(ch)) //quit on eof { if(ch )spaces;else if(ch \n)newlines; } 第…

C++_异常

目录 1、异常的关键字 2、异常的写法 3、异常的使用规则 3.1 规则1 3.2 规则2 3.3 规则3 3.4 规则4 3.5 规则5 4、异常的重新抛出 5、异常的规范 5.1 C98的异常规范 5.2 C11的异常规范 6、C标准库的异常体系 7、异常的优缺点 结语 前言&#xff1a; C的异常…

学习数据节构和算法的第15天

单链表的实现 链表的基本结构 #pragma once #include<stdio.h> typedf int SLTDataType; typedy struct SListNode {SLTDataType data;struct SListNode*next; }SLTNode;void Slisprint(SLTNode*phead);打印链表 #include<stdio.h> void SListPrint(SLTNode*phe…

详解DSLS达索许可管理器的安装与配置

DSLS的安装与配置 一、DSLS下载二、安装DLS三、使用DSLS四、更改计算机ID五、部分常见DSLS相关问题 一、DSLS下载 下载地址&#xff1a;https://software.3ds.com/?ticketST-5190987-dUM0dflc6zfjf04F5EXx-cas 注意&#xff1a;需要一个注册了的达索账号才能登录进去下载 一…

飞塔防火墙开局百篇——002.FortiGate上网配置——透明模式配置(Transparent)

透明模式配置 开启透明模式创建策略 在不改变现有网络拓扑前提下&#xff0c;将防火墙NGFW以透明模式部署到网络中&#xff0c;放在路由器和交换机之间&#xff0c;防火墙为透明模式&#xff0c;对内网网段192.168.1.0/24的上网进行4~7层的安全防护。 登陆FortiGate防火墙界面&…

24.网络游戏逆向分析与漏洞攻防-网络通信数据包分析工具-根据配置文件自动生成C语言头文件

免责声明&#xff1a;内容仅供学习参考&#xff0c;请合法利用知识&#xff0c;禁止进行违法犯罪活动&#xff01; 如果看不懂、不知道现在做的什么&#xff0c;那就跟着做完看效果 内容参考于&#xff1a;易道云信息技术研究院VIP课 上一个内容&#xff1a;23.实现配置工具…

【infiniband监控】grafana变量使用细化优化监控指标

本站以分享各种运维经验和运维所需要的技能为主 《python零基础入门》&#xff1a;python零基础入门学习 《python运维脚本》&#xff1a; python运维脚本实践 《shell》&#xff1a;shell学习 《terraform》持续更新中&#xff1a;terraform_Aws学习零基础入门到最佳实战 《k8…

Bitmap实现原理应用场景

Bitmap是什么&#xff1f; 用内存中连续的二进制位&#xff08;bit&#xff09;&#xff0c;用0或1标识数据是否存在。 长度为10的bitmap&#xff0c;1&#xff0c;2&#xff0c;3&#xff0c;4 在bitmap中存在。 Bitmap实现 1、字符串 数值对应字符串的下标、二进制位0&…

Centos7安装postgresql14步骤

1、进入网址 https://www.postgresql.org/download/ 2、按步骤执行 # Install the repository RPM: sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm# Install PostgreSQL: sudo yum install -y…

ST MotorControl Workbench 6.2.1 使用总结

目录 前言 软件安装 根据自己硬件配置参数 生成代码 开发板运行 ​ 总结 前言 好久没有玩ST的电机库了&#xff0c;已经更新到了MotorControl Workbench 6.2.1&#xff0c;6以上的版本比5的版本界面操作有很大的不同&#xff0c;核心算法有些增加。最近体验了一把使用自…

linux设置systemctl启动

linux设置nginx systemctl启动 生成nginx.pid文件 #验证nginx的配置&#xff0c;并生成nginx.pid文件 /usr/local/nginx/sbin/nginx -t #pid文件目录在 /usr/local/nginx/run/nginx.pid 设置systemctl启动nginx #添加之前需要先关闭启动状态的nginx&#xff0c;让nginx是未…

一款好用的AI工具——边界AICHAT(三)

目录 3.23、文档生成PPT演示3.24、AI文档翻译3.25、AI翻译3.26、论文模式3.27、文章批改3.28、文章纠正3.29、写作助手3.30、文言文翻译3.31、日报周报月报生成器3.32、OCR-DOC办公文档识别3.33、AI真人语音合成3.34、录音音频总结3.35、域方模型市场3.36、模型创建3.37、社区交…

Python 导入Excel三维坐标数据 生成三维曲面地形图(面) 4-4、线条平滑曲面(修改颜色)去除无效点

环境和包: 环境 python:python-3.12.0-amd64包: matplotlib 3.8.2 pandas 2.1.4 openpyxl 3.1.2 scipy 1.12.0 代码: import pandas as pd import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D from scipy.interpolate import griddata fro…

I2C驱动AT24C02

文章目录 一、硬件电路设备地址 二、使用步骤字节写:页写入:任意写:任意读: 一、硬件电路 设备地址 设备需要一个8位的设备地址字&#xff0c;后面跟着一个启动条件&#xff0c;以使芯片能够进行读或写操作 设备地址字由一个强制的1,0序列的前四个最有效的位&#xff0c;如所示…

(二)运行自己的stable-diffusion

前面的步骤如https://datawhaler.feishu.cn/docx/BwjzdQPJRonFh8xeiSOcRUI3n8b所示 拷贝、解压文件后&#xff0c;进入到stable-diffusion-webui的文件夹中&#xff0c;文件如下&#xff1a; 启动&#xff1a; 运行效果&#xff1a; 由于生成了好几个图&#xff0c;所以…

springboot的Converter和HttpMessageConveter

Converter和HttpMessageConveter是springboot和springmvc在处理请求的时候需要用到的。但是这两者的完全是不一样的&#xff0c;作用的地方也不一样。 1&#xff0c;springboot和springmvc处理请求的流程 先来回顾一下处理请求的流程&#xff1a; 用户向服务器发送请求&#…

Webbench,一个简单好用的web压力测试工具

Webbench 是一个简单且轻量级的Web服务器压力测试工具&#xff0c;它通过创建多个子进程来模拟多个客户端同时向服务器发送请求。运行平台是linux 安装Webbench: 1 下载Webbench源代码&#xff1a; wget http://www.ha97.com/code/webbench-1.5.tar.gz 2 解压源代码包&#…

焦点调制网络

摘要 https://arxiv.org/pdf/2203.11926.pdf 我们提出了焦点调制网络&#xff08;简称FocalNets&#xff09;&#xff0c;其中自注意力&#xff08;SA&#xff09;被焦点调制模块完全取代&#xff0c;用于在视觉中建模令牌交互。焦点调制包含三个组件&#xff1a;&#xff08;…

AIGC——ComfyUI 安装与基础使用

简介 ComfyUI是一个基于节点流程的稳定扩散操作界面&#xff0c;通过流程实现了更加精准的工作流定制和完善的可复现性。每个模块都有特定的功能&#xff0c;我们可以通过调整模块连接来实现不同的出图效果。然而&#xff0c;节点式的工作流也提高了一定的使用门槛。同时&…