- 授权协议: 未知
- 开发语言: Java
- 操作系统: 跨平台
- 软件首页: https://github.com/chenlei2/spring-boot-mybatis-rw
- 软件文档: https://github.com/chenlei2/spring-boot-mybatis-rw
- 官方下载: https://github.com/chenlei2/spring-boot-mybatis-rw
软件介绍
spring-boot-mybatis-rw
基于mybatis,springboot开箱即用的读写分离插件
Quick Start
介绍
此插件由以下2部分组成
datasource:读写数据源的代理,支持一写多读,用户只需实现 org.spring.boot.mybatis.rw.starter.datasource.AbstractReadRoutingDataSource这个类,实现自己读数据源的负载均衡算法
pulgin:mybatis插件实现读写路由
spring-boot 配置
spring.mybatis.rw.readDataSources[0].url=jdbc:MySql://localhost:3306/test?characterEncoding=UTF-8 spring.mybatis.rw.readDataSources[0].driverClassName=com.mysql.jdbc.Driver spring.mybatis.rw.readDataSources[0].username=root spring.mybatis.rw.readDataSources[0].password=123456 spring.mybatis.rw.readDataSources[1].url=jdbc:MySql://localhost:3306/test?characterEncoding=UTF-8 spring.mybatis.rw.readDataSources[1].driverClassName=com.mysql.jdbc.Driver spring.mybatis.rw.readDataSources[1].username=root spring.mybatis.rw.readDataSources[1].password=123456 spring.mybatis.rw.writeDataSource.url=jdbc:MySql://localhost:3306/chenlei?characterEncoding=UTF-8 spring.mybatis.rw.writeDataSource.driverClassName=com.mysql.jdbc.Driver spring.mybatis.rw.writeDataSource.username=root spring.mybatis.rw.writeDataSource.password=123456
XML配置
datasource:
<!--简单的一个master和多个slaver 读写分离的数据源 --> <bean id="dataSource" class="org.spring.boot.mybatis.rw.starter.datasource.impl.RoundRobinRWRoutingDataSourceProxy"> <property name="writeDataSource" ref="writeDS"/> <property name="readDataSoures"> <list> <ref bean="readDS"/> <ref bean="readDS"/> <ref bean="readDS"/> </list> </property> </bean>
总结
只需将数据源和事务工厂注入到sqlSessionFactory中,其他配置不变,便实现读写分离,对代码0入侵,配置简单,非常方便老项目的迁移。 详细配置
Perl语言入门
[美] Randal L.Schwartz、Tom Phoenix / 李晓峰 / 中国电力出版社 / 2002-8 / 48.00元
本书第一版于1993年问世,并从此成为畅销书。本书由Perl社区最著名、最活跃的两位成员写成,是Perl程序设计语言的精髓指南。 Perl最初只是Unix系统管理员的一个工具,在工作日里被用在无数的小任务中。从那以后,它逐步发展成为一种全功能的程序设计语言,特别是在各种计算平台上,它被用作Web编程、数据库处理、XML处理以及系统管理——它能够完成所有这些工作,同时仍然是处理小的日常工作的完......一起来看看 《Perl语言入门》 这本书的介绍吧!
