客栈网站建设代码,广州站是指哪个站,网站的服务,线上设计师招聘电商后台项目需要访问的数据源 多数据源方法#xff08;读写分离#xff09;
方法1#xff1a;jdk自带的dynamicdatasource
方法2#xff1a;Mybatis 方式
方法3#xff1a;dynamicdatasource框架 !--Druid连接池--dependencygroupIdcom.aliba…电商后台项目需要访问的数据源 多数据源方法读写分离
方法1jdk自带的dynamicdatasource
方法2Mybatis 方式
方法3dynamicdatasource框架 !--Druid连接池--dependencygroupIdcom.alibaba/groupIdartifactIddruid-spring-boot-starter/artifactIdversion1.2.3/version/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-aop/artifactId/dependencydependencygroupIdcom.baomidou/groupIdartifactIddynamic-datasource-spring-boot-starter/artifactIdversion3.5.0/version/dependencyspring:datasource:dynamic:#设置默认的数据源或者数据源组,默认值即为masterprimary: master#严格匹配数据源,默认false. true未匹配到指定数据源时抛异常,false使用默认数据源strict: falsedatasource:master:url: jdbc:mysql://127.0.0.1:3306/datasource1?serverTimezoneUTCuseUnicodetruecharacterEncodingUTF8useSSLfalseusername: rootpassword: 123456initial-size: 1min-idle: 1max-active: 20test-on-borrow: truedriver-class-name: com.mysql.cj.jdbc.Driverslave_1:url: jdbc:mysql://127.0.0.1:3306/datasource2?serverTimezoneUTCuseUnicodetruecharacterEncodingUTF8useSSLfalseusername: rootpassword: rootinitial-size: 1min-idle: 1max-active: 20test-on-borrow: truedriver-class-name: com.mysql.cj.jdbc.DriverGetMapping(value select)DS(slave_1)public ListFriend select(){return friendService.list();}GetMapping(value insert)DS(master)public void in(){Friend friend new Friend();friend.setName(loulan);friendService.save(friend);}