本文主要是介绍Mycat\atlas\sharding-jdbc,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
背景
数据库中间件选型思考
官网上安装、配置信息零散,需要使用者收集整理信息,在理解基础上正确配置,才能保证运行成功。这个工作比较耗时,希望读者看到此博客能快速run起来。
网络博客上也有很多人写Mycat和Atlas,绝大多数是针对Mycat和Atlas读写分离场景配置的。对Atlas,奇虎360在GitHub上开源了2个版本,一个版本为纯代理版,支持分表功能,另一个为Sharding版本。本次配置分库分表场景。
环境准备
部署架构
部署环境
MySQL:申请4个节点配置相同(虚拟机或物理机都可以),每个节点创建一个数据库,名称相同都为dbproxy,接着每个库创建一个相同表sbtest1
Mycat:下载Mycat-server-1.6-RELEASE-20161028204710-linux.tar.gz
Atlas:下载Atlas-sharding_1.0.1-el6.x86_64.rpm
创建一个表:sbtest1
sbtest1表结构为:
CREATE TABLE `sbtest1` (`id` int(10) unsigned NOT NULL,`k` int(10) unsigned NOT NULL DEFAULT '0',`c` char(120) NOT NULL DEFAULT '',`pad` char(60) NOT NULL DEFAULT '',PRIMARY KEY (`id`),KEY `k_1` (`k`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
sbtest1表结构为使用sysbench工具创建生成的,去掉了自增主键设置,后续就可以直接使用扩展版sysbench测试
中间件安装配置
Mycat安装配置
Mycat服务有2种配置方式,其一为在zookeeper上配置,启动后也会把内容写到*.xml几个文件中,其二是直接到*.xml修改配置,本次采用第二种方式简单方便。
安装
tar xzvf Mycat-server-1.6-RELEASE-20161028204710-linux.tar.gz
配置
server.xml账号和资源配置
<!DOCTYPE mycat:server SYSTEM "server.dtd">
<mycat:server xmlns:mycat="http://io.mycat/"><system><property name="useSqlStat">0</property> <!-- 1为开启实时统计、0为关闭 --><property name="useGlobleTableCheck">0</property> <!-- 1为开启全加班一致性检测、0为关闭 --><property name="sequnceHandlerType">2</property><property name="processorBufferPoolType">0</property><property name="serverPort">8066</property><property name="managerPort">9066</property> <property name="idleTimeout">300000</property> <property name="bindIp">0.0.0.0</property> <property name="processorExecutor">32</property> <property name="handleDistributedTransactions">0</property><property name="useOffHeapForMerge">1</property><property name="memoryPageSize">1m</property><property name="spillsFileBufferSize">1k</property><property name="useStreamOutput">0</property><property name="systemReserveMemorySize">384m</property><property name="useZKSwitch">true</property></system><user name="root"><property name="password">123456</property><property name="schemas">testdb</property></user><user name="user"><property name="password">123456</property><property name="schemas">testdb</property><property name="readOnly">true</property></user>
</mycat:server>
Mycat会对数据库访问资源进行管理,有2种类型账号,分为管理员、普通用户;管理员负责中间件各种资源管理(后端数据库访问)、查看、分配等,普通用户只能对数据库进行DDL和DML操作。每个用户配置了访问具体数据库资源,由schemas参数决定,未配置则无法访问。
schema.xml逻辑库配置
<?xml version="1.0"?>
<!DOCTYPE mycat:schema SYSTEM "schema.dtd">
<mycat:schema xmlns:mycat="http://io.mycat/"><schema name="testdb" checkSQLschema="false" sqlMaxLimit="10000" ><table name="sbtest1" primaryKey="id" dataNode="dn01,dn02,dn03,dn04" rule="mod-long" /></schema><dataNode name="dn01" dataHost="dbp1" database="dbproxy" /><dataNode name="dn02" dataHost="dbp2" database="dbproxy" /><dataNode name="dn03" dataHost="dbp3" database="dbproxy" /><dataNode name="dn04" dataHost="dbp4" database="dbproxy" /><dataHost name="dbp1" maxCon="2000" minCon="1000" balance="3" writeType="0" dbType="mysql" dbDriver="native" switchType="1" slaveThreshold="100"><heartbeat>select user()</heartbeat><writeHost host="dbpHostM1" url="ip01:3306" user="zhitao" password="iyw_=EseXx94"></writeHost> </dataHost><dataHost name="dbp2" maxCon="2000" minCon="1000" balance="3" writeType="0" dbType="mysql" dbDriver="native" switchType="1" slaveThreshold="100"><heartbeat>select user()</heartbeat><writeHost host="dbpHostM2" url="ip02:3306" user="zhitao" password="iyw_=EseXx94"></writeHost></dataHost> <dataHost name="dbp3" maxCon="2000" minCon="1000" balance="3" writeType="0" dbType="mysql" dbDriver="native" switchType="1" slaveThreshold="100"><heartbeat>select user()</heartbeat><writeHost host="dbpHostM3" url="ip03:3306" user="zhitao" password="iyw_=EseXx94"></writeHost></dataHost><dataHost name="dbp4" maxCon="2000" minCon="1000" balance="3" writeType="0" dbType="mysql" dbDriver="native" switchType="1" slaveThreshold="100"><heartbeat>select user()</heartbeat><writeHost host="dbpHostM4" url="ip04:3306" user="zhitao" password="iyw_=EseXx94"></writeHost></dataHost>
</mycat:schema>
以上配置了4个逻辑库,只有主库没配从库,如有需要读者可以加上,一个表sbtest1数据切分到4个逻辑库上。其中’rule=”mod-long”‘表示选择取模算法,对应下面的配置
rule.xml分片规则配置
......<function name="mod-long" class="io.mycat.route.function.PartitionByMod"><!-- how many data nodes --><property name="count">4</property></function>
......
表示id % 4 = 路由到对应逻辑库上(dbp1|dbp2|dbp3|dbp4)
成功执行一条SQL语句:
Atlas安装配置
Atlas配置相对较简单,配置项和文件都比Mycat要少
安装
1.执行如下命令
sudo rpm –i Atlas-XX.el6.x86_64.rpm
默认安装目录:/usr/local/mysql-proxy
2.配置test.cnf
进入conf目录
[mysql-proxy]
admin-username = user
admin-password = 123456
#配置代理或读写分离主库配置
admin-lua-script = /usr/local/mysql-proxy/lib/mysql-proxy/lua/admin.lua#Atlas后端连接的MySQL主库的IP和端口,可设置多项,用逗号分隔
#proxy-backend-addresses = ip01:3306,ip02:3306#Atlas后端连接的MySQL从库的IP和端口,@后面的数字代表权重,用来作负载均衡,若省略则默认为1,可设置多项,用逗号分隔
#proxy-read-only-backend-addresses = readonlyIP01:3306,readonlyIP02:3306#示例,配置代理主库配置
proxy-backend-addresses = ipxxx:3306daemon = true
keepalive = false
#libevent线程数配置
event-threads = 32
log-level = error
#日志路径
log-path = /usr/local/mysql-proxy/log
sql-log = OFF
#代理端口配置,用于操作数据库
proxy-address = 0.0.0.0:1234
#管理端口配置,用于管理资源,监控,系统信息操作、查看等
admin-address = 0.0.0.0:2345
charset = UTF8
wait-timeout = 3600
#Atlas密码需要加密,安装Atlas进入bin目录,执行:./encrypt mysql数据库密码;生成加密串拷贝上去
pwds = zhitao:If2Il8Bd7YgWZ+vzsw3ZlQ==[shardrule-0]
table = dbproxy.sbtest1
# sharding类型:range或hash,本次
type = hash
# 分片字段名
shard-key = id
# 0:0-999,1:1000-1999 #分片的group,如果是range类型的sharding,则groups的格式是:group_id:id范围。如果是hash类型的sharding,则groups的格式是:group_id。例如groups = 0, 1
groups = 0,1,2,3[group-0]
# master
proxy-backend-addresses=ip01:3306[group-1]
proxy-backend-addresses=ip02:3306[group-2]
proxy-backend-addresses=ip03:3306[group-3]
proxy-backend-addresses=ip04:3306
登录Atlas:
执行SQL Atlas:
注意:配置分库分表时,只有指定的分表才会执行shardrule流程,其他表走正常请求流程,所以要配置proxy-backend-addresses,从库配置视部署情况可选
Sharding-JDBC介绍:
整合spring+mybatis+sharding-jdbc
Sharding-JDBC
直接封装JDBC API
,可以理解为增强版的JDBC
驱动,旧代码迁移成本几乎为零:
- 可适用于任何基于
java
的ORM
框架,如:JPA
,Hibernate
,Mybatis
,Spring JDBC Template
或直接使用JDBC
。 - 可基于任何第三方的数据库连接池,如:
DBCP
,C3P0
,BoneCP
,Druid
等。 - 理论上可支持任意实现
JDBC
规范的数据库。虽然目前仅支持MySQL
,但已有支持Oracle
,SQLServer
,DB2
等数据库的计划。
Sharding-JDBC
定位为轻量级java
框架,使用客户端直连数据库,以jar
包形式提供服务,未使用中间层,无需额外部署,无其他依赖,DBA
也无需改变原有的运维方式。SQL
解析使用Druid
解析器,是目前性能最高的SQL
解析器。
Sharding-JDBC
功能灵活且全面:
- 分片策略灵活,可支持
=
,BETWEEN
,IN
等多维度分片,也可支持多分片键共用。 SQL
解析功能完善,支持聚合,分组,排序,Limit
,OR
等查询,并且支持Binding Table
以及笛卡尔积的表查询。- 支持柔性事务(目前仅最大努力送达型)。
- 支持读写分离。
Sharding-JDBC
配置多样:
- 可支持YAML和Spring命名空间配置
- 灵活多样的
inline
方式
pom.xml
[java] view plain copy print?
- <span style="white-space:pre"> </span><dependency>
- <span style="white-space:pre"> </span><groupId>com.dangdang</groupId>
- <artifactId>sharding-jdbc-core</artifactId>
- <version>1.3.2</version>
- </dependency>
- <dependency>
- <groupId>com.dangdang</groupId>
- <artifactId>sharding-jdbc-config-spring</artifactId>
- <version>1.3.2</version>
- </dependency>
- <dependency>
- <groupId>com.dangdang</groupId>
- <artifactId>sharding-jdbc-config-common</artifactId>
- <version>1.3.2</version>
- </dependency>
<span style="white-space:pre"> </span><dependency><span style="white-space:pre"> </span><groupId>com.dangdang</groupId><artifactId>sharding-jdbc-core</artifactId><version>1.3.2</version></dependency><dependency><groupId>com.dangdang</groupId><artifactId>sharding-jdbc-config-spring</artifactId><version>1.3.2</version></dependency><dependency><groupId>com.dangdang</groupId><artifactId>sharding-jdbc-config-common</artifactId><version>1.3.2</version></dependency>
创建三个库,一主(dbtal_0_master)两从(dbtal_0_slave_0、dbtal_0_slave_1)
建表语句
[sql] view plain copy print?
- SET FOREIGN_KEY_CHECKS=0;
- -- ----------------------------
- -- Table structure for t_user_0
- -- ----------------------------
- DROP TABLE IF EXISTS `t_user_0`;
- CREATE TABLE `t_user_0` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `user_id` int(11) NOT NULL,
- `name` varchar(255) NOT NULL,
- `age` int(11) NOT NULL,
- PRIMARY KEY (`id`)
- ) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;
- -- ----------------------------
- -- Table structure for t_user_1
- -- ----------------------------
- DROP TABLE IF EXISTS `t_user_1`;
- CREATE TABLE `t_user_1` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `user_id` int(11) NOT NULL,
- `name` varchar(255) NOT NULL,
- `age` int(11) NOT NULL,
- PRIMARY KEY (`id`)
- ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
- -- ----------------------------
- -- Table structure for t_user_2
- -- ----------------------------
- DROP TABLE IF EXISTS `t_user_2`;
- CREATE TABLE `t_user_2` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `user_id` int(11) NOT NULL,
- `name` varchar(255) NOT NULL,
- `age` int(11) NOT NULL,
- PRIMARY KEY (`id`)
- ) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=utf8;
SET FOREIGN_KEY_CHECKS=0;-- ----------------------------
-- Table structure for t_user_0
-- ----------------------------
DROP TABLE IF EXISTS `t_user_0`;
CREATE TABLE `t_user_0` (`id` int(11) NOT NULL AUTO_INCREMENT,`user_id` int(11) NOT NULL,`name` varchar(255) NOT NULL,`age` int(11) NOT NULL,PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;-- ----------------------------
-- Table structure for t_user_1
-- ----------------------------
DROP TABLE IF EXISTS `t_user_1`;
CREATE TABLE `t_user_1` (`id` int(11) NOT NULL AUTO_INCREMENT,`user_id` int(11) NOT NULL,`name` varchar(255) NOT NULL,`age` int(11) NOT NULL,PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;-- ----------------------------
-- Table structure for t_user_2
-- ----------------------------
DROP TABLE IF EXISTS `t_user_2`;
CREATE TABLE `t_user_2` (`id` int(11) NOT NULL AUTO_INCREMENT,`user_id` int(11) NOT NULL,`name` varchar(255) NOT NULL,`age` int(11) NOT NULL,PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=utf8;
User.java
[java] view plain copy print?
- /**
- * @filename User.java
- * @version www.mindai.com
- * @date 2016年10月26日
- */
- package com.mjkf.demo.domain.model;
- import javax.persistence.Id;
- import javax.persistence.Table;
- import com.mjkf.framework.core.base.model.BaseModel;
- /**
- * @author farrell
- * @date 2016年10月26日
- */
- @Table(name="t_user")
- public class User extends BaseModel {
- /**
- * serialVersionUID
- * @since Ver 1.1
- */
- private static final long serialVersionUID = -4044598743926228429L;
- @Id
- private Integer id;
- private Integer userId;
- private String name;
- private Integer age;
- public Integer getId() {
- return id;
- }
- public void setId(Integer id) {
- this.id = id;
- }
- public Integer getUserId() {
- return userId;
- }
- public void setUserId(Integer userId) {
- this.userId = userId;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public Integer getAge() {
- return age;
- }
- public void setAge(Integer age) {
- this.age = age;
- }
- @Override
- public String toString() {
- return "User [id=" + id + ", userId=" + userId + ", name=" + name + ", age=" + age + "]";
- }
- }
/** * @filename User.java * @version www.mindai.com * @date 2016年10月26日 */
package com.mjkf.demo.domain.model;import javax.persistence.Id;
import javax.persistence.Table;import com.mjkf.framework.core.base.model.BaseModel;/** * @author farrell * @date 2016年10月26日 */@Table(name="t_user")
public class User extends BaseModel {/** * serialVersionUID * @since Ver 1.1 */ private static final long serialVersionUID = -4044598743926228429L;@Idprivate Integer id;private Integer userId;private String name;private Integer age;public Integer getId() {return id;}public void setId(Integer id) {this.id = id;}public Integer getUserId() {return userId;}public void setUserId(Integer userId) {this.userId = userId;}public String getName() {return name;}public void setName(String name) {this.name = name;}public Integer getAge() {return age;}public void setAge(Integer age) {this.age = age;}@Overridepublic String toString() {return "User [id=" + id + ", userId=" + userId + ", name=" + name + ", age=" + age + "]";}
}
UserMapper.java
[java] view plain copy print?
- /**
- * @filename UserMapper.java
- * @version www.mindai.com
- * @date 2016年10月26日
- */
- package com.mjkf.demo.mapper;
- import com.mjkf.demo.domain.model.User;
- import com.mjkf.framework.core.base.mapper.IBaseMapper;
- /**
- * @author farrell
- * @date 2016年10月26日
- */
- public interface UserMapper extends IBaseMapper<User>{
- }
/** * @filename UserMapper.java * @version www.mindai.com * @date 2016年10月26日 */
package com.mjkf.demo.mapper;import com.mjkf.demo.domain.model.User;
import com.mjkf.framework.core.base.mapper.IBaseMapper;/** * @author farrell * @date 2016年10月26日 */
public interface UserMapper extends IBaseMapper<User>{}
IUserService.java
[java] view plain copy print?
- /**
- * @filename IUserService.java
- * @version www.mindai.com
- * @date 2016年10月26日
- */
- package com.mjkf.demo.service;
- import com.mjkf.demo.domain.model.User;
- import com.mjkf.framework.core.base.service.IService;
- import com.mjkf.framework.mybatis.mapper.entity.Example;
- /**
- * @author farrell
- * @date 2016年10月26日
- */
- public interface IUserService extends IService<User>{
- void updateByExample(User user,Example example);
- }
/** * @filename IUserService.java * @version www.mindai.com * @date 2016年10月26日 */
package com.mjkf.demo.service;import com.mjkf.demo.domain.model.User;
import com.mjkf.framework.core.base.service.IService;
import com.mjkf.framework.mybatis.mapper.entity.Example;/** * @author farrell * @date 2016年10月26日 */
public interface IUserService extends IService<User>{void updateByExample(User user,Example example);
}
UserServiceImpl.java
[java] view plain copy print?
- package com.mjkf.demo.service.impl;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import com.mjkf.demo.domain.model.User;
- import com.mjkf.demo.mapper.UserMapper;
- import com.mjkf.demo.service.IUserService;
- import com.mjkf.framework.core.base.service.BaseService;
- import com.mjkf.framework.mybatis.mapper.entity.Example;
- @Service
- public class UserServiceImpl extends BaseService<User> implements IUserService{
- @Autowired
- UserMapper userMapper;
- @Override
- public void updateByExample(User record,Example example) {
- userMapper.updateByExampleSelective(record, example);
- }
- }
package com.mjkf.demo.service.impl;import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;import com.mjkf.demo.domain.model.User;
import com.mjkf.demo.mapper.UserMapper;
import com.mjkf.demo.service.IUserService;
import com.mjkf.framework.core.base.service.BaseService;
import com.mjkf.framework.mybatis.mapper.entity.Example;@Service
public class UserServiceImpl extends BaseService<User> implements IUserService{@AutowiredUserMapper userMapper;@Overridepublic void updateByExample(User record,Example example) {userMapper.updateByExampleSelective(record, example);}}
MySingleKeyTableShardingAlgorithm.java
[java] view plain copy print?
- /**
- * @filename SingleKeyTableShardingAlgorithm.java
- * @version www.mindai.com
- * @date 2016年10月25日
- */
- package com.mjkf.demo.sharding;
- import java.util.Collection;
- import java.util.LinkedHashSet;
- import com.dangdang.ddframe.rdb.sharding.api.ShardingValue;
- import com.dangdang.ddframe.rdb.sharding.api.strategy.table.SingleKeyTableShardingAlgorithm;
- import com.google.common.collect.Range;
- /**
- * @author farrell
- * @date 2016年10月25日
- */
- public class MySingleKeyTableShardingAlgorithm implements SingleKeyTableShardingAlgorithm<Integer>{
- /**
- * sql 中 = 操作时,table的映射
- */
- @Override
- public String doEqualSharding(final Collection<String> tableNames, final ShardingValue<Integer> shardingValue) {
- for (String each : tableNames) {
- if (each.endsWith(shardingValue.getValue() % 3 + "")) {
- return each;
- }
- }
- throw new UnsupportedOperationException();
- }
- /**
- * sql 中 in 操作时,table的映射
- */
- @Override
- public Collection<String> doInSharding(final Collection<String> tableNames, final ShardingValue<Integer> shardingValue) {
- Collection<String> result = new LinkedHashSet<>(tableNames.size());
- for (Integer value : shardingValue.getValues()) {
- for (String tableName : tableNames) {
- if (tableName.endsWith(value % 3 + "")) {
- result.add(tableName);
- }
- }
- }
- return result;
- }
- /**
- * sql 中 between 操作时,table的映射
- */
- @Override
- public Collection<String> doBetweenSharding(final Collection<String> tableNames, final ShardingValue<Integer> shardingValue) {
- Collection<String> result = new LinkedHashSet<>(tableNames.size());
- Range<Integer> range = shardingValue.getValueRange();
- for (Integer i = range.lowerEndpoint(); i <= range.upperEndpoint(); i++) {
- for (String each : tableNames) {
- if (each.endsWith(i % 3 + "")) {
- result.add(each);
- }
- }
- }
- return result;
- }
- }
/** * @filename SingleKeyTableShardingAlgorithm.java * @version www.mindai.com * @date 2016年10月25日 */
package com.mjkf.demo.sharding;import java.util.Collection;
import java.util.LinkedHashSet;import com.dangdang.ddframe.rdb.sharding.api.ShardingValue;
import com.dangdang.ddframe.rdb.sharding.api.strategy.table.SingleKeyTableShardingAlgorithm;
import com.google.common.collect.Range;
/** * @author farrell * @date 2016年10月25日 */
public class MySingleKeyTableShardingAlgorithm implements SingleKeyTableShardingAlgorithm<Integer>{/*** sql 中 = 操作时,table的映射 */@Overridepublic String doEqualSharding(final Collection<String> tableNames, final ShardingValue<Integer> shardingValue) {for (String each : tableNames) {if (each.endsWith(shardingValue.getValue() % 3 + "")) {return each;}}throw new UnsupportedOperationException();}/*** sql 中 in 操作时,table的映射 */@Overridepublic Collection<String> doInSharding(final Collection<String> tableNames, final ShardingValue<Integer> shardingValue) {Collection<String> result = new LinkedHashSet<>(tableNames.size());for (Integer value : shardingValue.getValues()) {for (String tableName : tableNames) {if (tableName.endsWith(value % 3 + "")) {result.add(tableName);}}}return result;}/*** sql 中 between 操作时,table的映射 */@Overridepublic Collection<String> doBetweenSharding(final Collection<String> tableNames, final ShardingValue<Integer> shardingValue) {Collection<String> result = new LinkedHashSet<>(tableNames.size());Range<Integer> range = shardingValue.getValueRange();for (Integer i = range.lowerEndpoint(); i <= range.upperEndpoint(); i++) {for (String each : tableNames) {if (each.endsWith(i % 3 + "")) {result.add(each);}}}return result;}
}
UserMapper.xml
[html] view plain copy print?
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd" >
- <mapper namespace="com.mjkf.demo.mapper.UserMapper">
- </mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd" >
<mapper namespace="com.mjkf.demo.mapper.UserMapper">
</mapper>
applicationContext.xml
[html] view plain copy print?
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:p="http://www.springframework.org/schema/p"
- xmlns:aop="http://www.springframework.org/schema/aop"
- xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns:jee="http://www.springframework.org/schema/jee"
- xmlns:util="http://www.springframework.org/schema/util"
- xmlns:rdb="http://www.dangdang.com/schema/ddframe/rdb"
- xsi:schemaLocation="
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context-3.2.xsd
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
- http://www.springframework.org/schema/tx
- http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
- http://www.springframework.org/schema/aop
- http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
- http://www.springframework.org/schema/jee
- http://www.springframework.org/schema/jee/spring-jee-3.2.xsd
- http://www.springframework.org/schema/util
- http://www.springframework.org/schema/util/spring-util-3.2.xsd
- http://www.dangdang.com/schema/ddframe/rdb
- http://www.dangdang.com/schema/ddframe/rdb/rdb.xsd ">
- <description>Spring公共配置</description>
- <!--开启注解 -->
- <context:annotation-config/>
- <context:component-scan base-package="com.mjkf">
- <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" />
- </context:component-scan>
- <!-- 定义受环境影响易变的变量 -->
- <bean id="propertyConfigurer" class="com.mjkf.framework.utils.properties.WebPropertyPlaceholderConfigurer">
- <property name="locations">
- <list>
- <value>classpath:jdbc.properties</value>
- </list>
- </property>
- </bean>
- <!-- 阿里 druid数据库连接池 -->
- <!-- 写数据源-->
- <bean id="dataSource_master" class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close">
- <property name="url" value="${jdbc0.url}" />
- <property name="username" value="${jdbc0.username}" />
- <property name="password" value="${jdbc0.password}" />
- <!-- <property name="driverClass" value="${jdbc_driver0}" /> -->
- <!-- 初始化连接大小 -->
- <property name="initialSize" value="0" />
- <!-- 连接池最大使用连接数量 -->
- <property name="maxActive" value="20" />
- <!-- 连接池最小空闲 -->
- <property name="minIdle" value="0" />
- <!-- 获取连接最大等待时间 -->
- <property name="maxWait" value="60000" />
- <property name="validationQuery" value="${validationQuery}" />
- <property name="testOnBorrow" value="false" />
- <property name="testOnReturn" value="false" />
- <property name="testWhileIdle" value="true" />
- <!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
- <property name="timeBetweenEvictionRunsMillis" value="60000" />
- <!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
- <property name="minEvictableIdleTimeMillis" value="25200000" />
- <!-- 打开removeAbandoned功能 -->
- <property name="removeAbandoned" value="true" />
- <!-- 1800秒,也就是30分钟 -->
- <property name="removeAbandonedTimeout" value="1800" />
- <!-- 关闭abanded连接时输出错误日志 -->
- <property name="logAbandoned" value="true" />
- <property name="filters" value="stat" />
- </bean>
- <!-- 读数据源一,可多个-->
- <bean id="dataSource_slave" class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close">
- <property name="url" value="${jdbc1.url}" />
- <property name="username" value="${jdbc1.username}" />
- <property name="password" value="${jdbc1.password}" />
- <!-- <property name="driverClass" value="${jdbc_driver1}" /> -->
- <!-- 初始化连接大小 -->
- <property name="initialSize" value="0" />
- <!-- 连接池最大使用连接数量 -->
- <property name="maxActive" value="20" />
- <!-- 连接池最小空闲 -->
- <property name="minIdle" value="0" />
- <!-- 获取连接最大等待时间 -->
- <property name="maxWait" value="60000" />
- <property name="validationQuery" value="${validationQuery}" />
- <property name="testOnBorrow" value="false" />
- <property name="testOnReturn" value="false" />
- <property name="testWhileIdle" value="true" />
- <!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
- <property name="timeBetweenEvictionRunsMillis" value="60000" />
- <!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
- <property name="minEvictableIdleTimeMillis" value="25200000" />
- <!-- 打开removeAbandoned功能 -->
- <property name="removeAbandoned" value="true" />
- <!-- 1800秒,也就是30分钟 -->
- <property name="removeAbandonedTimeout" value="1800" />
- <!-- 关闭abanded连接时输出错误日志 -->
- <property name="logAbandoned" value="true" />
- <property name="filters" value="stat" />
- </bean>
- <!-- 配置主从 -->
- <rdb:master-slave-data-source id="datasource_01" master-data-source-ref="dataSource_master" slave-data-sources-ref="dataSource_slave" />
- <rdb:strategy id="userTableStrategy" sharding-columns="USER_ID" algorithm-class="com.mjkf.demo.sharding.MySingleKeyTableShardingAlgorithm"/>
- <rdb:data-source id="shardingDataSource">
- <rdb:sharding-rule data-sources="datasource_01">
- <rdb:table-rules>
- <rdb:table-rule logic-table="t_user" actual-tables="t_user_0,t_user_1,t_user_2" table-strategy="userTableStrategy"/>
- </rdb:table-rules>
- </rdb:sharding-rule>
- </rdb:data-source>
- <!-- mybatis文件 -->
- <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
- <property name="dataSource" ref="shardingDataSource" />
- <!-- 自动扫描entity目录, 省掉Configuration.xml里的手工配置 -->
- <property name="mapperLocations">
- <array>
- <value>classpath:mapper/*Mapper.xml</value>
- </array>
- </property>
- <property name="typeAliasesPackage" value="com.mjkf.demo.domain.model" />
- <property name="configLocation" value="classpath:mybatis-config.xml"/>
- </bean>
- <bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate" scope="prototype">
- <constructor-arg index="0" ref="sqlSessionFactory"/>
- <constructor-arg index="1" value="BATCH" />
- </bean>
- <bean class="com.mjkf.framework.mybatis.spring.mapper.MapperScannerConfigurer">
- <property name="basePackage" value="com.mjkf.demo.mapper" />
- <property name="markerInterface" value="com.mjkf.framework.core.base.mapper.IBaseMapper"/>
- </bean>
- <!-- 开启注解事务 只对当前配置文件有效 -->
- <tx:annotation-driven transaction-manager="transactionManager" />
- <bean id="transactionManager"
- class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
- <property name="dataSource" ref="shardingDataSource" />
- </bean>
- <!-- 拦截器方式配置事物 -->
- <tx:advice id="transactionAdvice" transaction-manager="transactionManager">
- <tx:attributes>
- <tx:method name="do*" propagation="REQUIRED" />
- <tx:method name="save*" propagation="REQUIRED" />
- <tx:method name="update*" propagation="REQUIRED" />
- <tx:method name="delete*" propagation="REQUIRED" />
- <tx:method name="process*" propagation="REQUIRED" />
- <tx:method name="inser*" propagation="REQUIRED" />
- <tx:method name="send*" propagation="REQUIRED" />
- <tx:method name="put*" read-only="true"/>
- <tx:method name="query*" read-only="true"/>
- <tx:method name="page*" read-only="true"/>
- <tx:method name="get*" read-only="true" />
- <tx:method name="count*" read-only="true" />
- <tx:method name="find*" read-only="true" />
- <tx:method name="list*" read-only="true" />
- <tx:method name="*" propagation="REQUIRED"/>
- </tx:attributes>
- </tx:advice>
- <aop:aspectj-autoproxy proxy-target-class="true" />
- <aop:config expose-proxy="true">
- <!-- 只对业务逻辑层实施事务 -->
- <aop:pointcut id="transactionPointCut" expression="execution(* com.mjkf.*.*.impl.*Impl.*(..))" />
- <aop:advisor pointcut-ref="transactionPointCut" advice-ref="transactionAdvice" />
- </aop:config>
- </beans>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"xmlns:context="http://www.springframework.org/schema/context"xmlns:jee="http://www.springframework.org/schema/jee" xmlns:util="http://www.springframework.org/schema/util"xmlns:rdb="http://www.dangdang.com/schema/ddframe/rdb"xsi:schemaLocation="http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.2.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsdhttp://www.dangdang.com/schema/ddframe/rdb http://www.dangdang.com/schema/ddframe/rdb/rdb.xsd "><description>Spring公共配置</description><!--开启注解 --><context:annotation-config/><context:component-scan base-package="com.mjkf"><context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" /></context:component-scan><!-- 定义受环境影响易变的变量 --><bean id="propertyConfigurer" class="com.mjkf.framework.utils.properties.WebPropertyPlaceholderConfigurer"><property name="locations"><list><value>classpath:jdbc.properties</value></list></property></bean><!-- 阿里 druid数据库连接池 --><!-- 写数据源--><bean id="dataSource_master" class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close"><property name="url" value="${jdbc0.url}" /><property name="username" value="${jdbc0.username}" /><property name="password" value="${jdbc0.password}" />
<!-- <property name="driverClass" value="${jdbc_driver0}" /> --><!-- 初始化连接大小 --><property name="initialSize" value="0" /><!-- 连接池最大使用连接数量 --><property name="maxActive" value="20" /><!-- 连接池最小空闲 --><property name="minIdle" value="0" /><!-- 获取连接最大等待时间 --><property name="maxWait" value="60000" /><property name="validationQuery" value="${validationQuery}" /><property name="testOnBorrow" value="false" /><property name="testOnReturn" value="false" /><property name="testWhileIdle" value="true" /><!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 --><property name="timeBetweenEvictionRunsMillis" value="60000" /><!-- 配置一个连接在池中最小生存的时间,单位是毫秒 --><property name="minEvictableIdleTimeMillis" value="25200000" /><!-- 打开removeAbandoned功能 --><property name="removeAbandoned" value="true" /><!-- 1800秒,也就是30分钟 --><property name="removeAbandonedTimeout" value="1800" /><!-- 关闭abanded连接时输出错误日志 --><property name="logAbandoned" value="true" /><property name="filters" value="stat" /></bean><!-- 读数据源一,可多个--><bean id="dataSource_slave" class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close"><property name="url" value="${jdbc1.url}" /><property name="username" value="${jdbc1.username}" /><property name="password" value="${jdbc1.password}" />
<!-- <property name="driverClass" value="${jdbc_driver1}" /> --><!-- 初始化连接大小 --><property name="initialSize" value="0" /><!-- 连接池最大使用连接数量 --><property name="maxActive" value="20" /><!-- 连接池最小空闲 --><property name="minIdle" value="0" /><!-- 获取连接最大等待时间 --><property name="maxWait" value="60000" /><property name="validationQuery" value="${validationQuery}" /><property name="testOnBorrow" value="false" /><property name="testOnReturn" value="false" /><property name="testWhileIdle" value="true" /><!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 --><property name="timeBetweenEvictionRunsMillis" value="60000" /><!-- 配置一个连接在池中最小生存的时间,单位是毫秒 --><property name="minEvictableIdleTimeMillis" value="25200000" /><!-- 打开removeAbandoned功能 --><property name="removeAbandoned" value="true" /><!-- 1800秒,也就是30分钟 --><property name="removeAbandonedTimeout" value="1800" /><!-- 关闭abanded连接时输出错误日志 --><property name="logAbandoned" value="true" /><property name="filters" value="stat" /></bean><!-- 配置主从 --><rdb:master-slave-data-source id="datasource_01" master-data-source-ref="dataSource_master" slave-data-sources-ref="dataSource_slave" /><rdb:strategy id="userTableStrategy" sharding-columns="USER_ID" algorithm-class="com.mjkf.demo.sharding.MySingleKeyTableShardingAlgorithm"/><rdb:data-source id="shardingDataSource"><rdb:sharding-rule data-sources="datasource_01"><rdb:table-rules><rdb:table-rule logic-table="t_user" actual-tables="t_user_0,t_user_1,t_user_2" table-strategy="userTableStrategy"/></rdb:table-rules></rdb:sharding-rule></rdb:data-source><!-- mybatis文件 --><bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"><property name="dataSource" ref="shardingDataSource" /><!-- 自动扫描entity目录, 省掉Configuration.xml里的手工配置 --><property name="mapperLocations"><array><value>classpath:mapper/*Mapper.xml</value></array></property><property name="typeAliasesPackage" value="com.mjkf.demo.domain.model" /><property name="configLocation" value="classpath:mybatis-config.xml"/></bean><bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate" scope="prototype"><constructor-arg index="0" ref="sqlSessionFactory"/><constructor-arg index="1" value="BATCH" /></bean><bean class="com.mjkf.framework.mybatis.spring.mapper.MapperScannerConfigurer"><property name="basePackage" value="com.mjkf.demo.mapper" /><property name="markerInterface" value="com.mjkf.framework.core.base.mapper.IBaseMapper"/></bean><!-- 开启注解事务 只对当前配置文件有效 --><tx:annotation-driven transaction-manager="transactionManager" /><bean id="transactionManager"class="org.springframework.jdbc.datasource.DataSourceTransactionManager"><property name="dataSource" ref="shardingDataSource" /></bean><!-- 拦截器方式配置事物 --><tx:advice id="transactionAdvice" transaction-manager="transactionManager"><tx:attributes><tx:method name="do*" propagation="REQUIRED" /><tx:method name="save*" propagation="REQUIRED" /><tx:method name="update*" propagation="REQUIRED" /><tx:method name="delete*" propagation="REQUIRED" /><tx:method name="process*" propagation="REQUIRED" /><tx:method name="inser*" propagation="REQUIRED" /><tx:method name="send*" propagation="REQUIRED" /><tx:method name="put*" read-only="true"/><tx:method name="query*" read-only="true"/><tx:method name="page*" read-only="true"/><tx:method name="get*" read-only="true" /><tx:method name="count*" read-only="true" /><tx:method name="find*" read-only="true" /><tx:method name="list*" read-only="true" /><tx:method name="*" propagation="REQUIRED"/></tx:attributes></tx:advice><aop:aspectj-autoproxy proxy-target-class="true" /><aop:config expose-proxy="true"><!-- 只对业务逻辑层实施事务 --><aop:pointcut id="transactionPointCut" expression="execution(* com.mjkf.*.*.impl.*Impl.*(..))" /><aop:advisor pointcut-ref="transactionPointCut" advice-ref="transactionAdvice" /></aop:config>
</beans>
MainTest.java
[java] view plain copy print?
- /**
- * @filename MainTest.java
- * @version www.mindai.com
- * @date 2016年10月25日
- */
- package test.mjkf;
- import java.util.List;
- import org.junit.Test;
- import org.junit.runner.RunWith;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.test.context.ContextConfiguration;
- import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
- import com.mjkf.demo.domain.model.User;
- import com.mjkf.demo.service.IUserService;
- import com.mjkf.framework.mybatis.mapper.entity.Example;
- import com.mjkf.framework.mybatis.mapper.entity.Example.Criteria;
- /**
- * @author farrell
- * @date 2016年10月25日
- */
- @RunWith(SpringJUnit4ClassRunner.class)
- @ContextConfiguration(locations = { "classpath*:spring/applicationContext.xml" })
- public class MainTest {
- @Autowired
- IUserService userService;
- @Test
- public void test(){
- System.out.println("sharding-demo start................");
- User entity = new User();
- entity.setUserId(1);
- List<User> list = userService.find(entity);
- System.out.println(list.size());
- for (User user : list) {
- System.out.println(user.getUserId()+"------->"+user.getName());
- }
- System.out.println("======================分割线===========================");
- List<User> users = userService.findAll();
- for (User user : users) {
- System.out.println(user.getUserId()+"------->"+user.getName());
- }
- System.out.println("执行插入语句");
- User user = new User();
- user.setUserId(1002);
- user.setName("李四");
- user.setAge(18);
- userService.save(user);
- System.out.println("======================分割线===========================");
- System.out.println("执行更新语句");
- User user1 = new User();
- user1.setId(24);
- user1.setUserId(1001);
- user1.setName("李四update");
- user1.setAge(18);
- userService.update(user1);
- System.out.println("======================分割线===========================");
- // System.out.println("执行删除语句");
- // User user2 = new User();
- // user2.setUserId(1001);
- // userService.delete(user2);
- // System.out.println("======================分割线===========================");
- Example example = new Example(User.class);
- Criteria criteria = example.createCriteria();
- criteria.andEqualTo("userId", 1001);
- User user2 = new User();
- user2.setName("李四update2");
- user2.setUserId(1001);
- user2.setAge(19);
- userService.updateByExample(user2,example);
- }
- }
/** * @filename MainTest.java * @version www.mindai.com * @date 2016年10月25日 */
package test.mjkf;import java.util.List;import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;import com.mjkf.demo.domain.model.User;
import com.mjkf.demo.service.IUserService;
import com.mjkf.framework.mybatis.mapper.entity.Example;
import com.mjkf.framework.mybatis.mapper.entity.Example.Criteria;/** * @author farrell * @date 2016年10月25日 */@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath*:spring/applicationContext.xml" })
public class MainTest {@AutowiredIUserService userService;@Testpublic void test(){System.out.println("sharding-demo start................");User entity = new User();entity.setUserId(1);List<User> list = userService.find(entity);System.out.println(list.size());for (User user : list) {System.out.println(user.getUserId()+"------->"+user.getName());}System.out.println("======================分割线===========================");List<User> users = userService.findAll();for (User user : users) {System.out.println(user.getUserId()+"------->"+user.getName());}System.out.println("执行插入语句");User user = new User();user.setUserId(1002);user.setName("李四");user.setAge(18);userService.save(user);System.out.println("======================分割线===========================");System.out.println("执行更新语句");User user1 = new User();user1.setId(24);user1.setUserId(1001);user1.setName("李四update");user1.setAge(18);userService.update(user1);System.out.println("======================分割线===========================");// System.out.println("执行删除语句");
// User user2 = new User();
// user2.setUserId(1001);
// userService.delete(user2);
// System.out.println("======================分割线===========================");Example example = new Example(User.class);Criteria criteria = example.createCriteria();criteria.andEqualTo("userId", 1001);User user2 = new User();user2.setName("李四update2");user2.setUserId(1001);user2.setAge(19);userService.updateByExample(user2,example);}
}
输出日志如下:
[html] view plain copy print?
- 2016-10-28 17:20:15 [DEBUG]-[org.mybatis.spring.SqlSessionUtils] Creating a new SqlSession
- 2016-10-28 17:20:15 [DEBUG]-[org.mybatis.spring.SqlSessionUtils] SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1c05239a] was not registered for synchronization because synchronization is not active
- 2016-10-28 17:20:15 [DEBUG]-[org.springframework.jdbc.datasource.DataSourceUtils] Fetching JDBC Connection from DataSource
- 2016-10-28 17:20:15 [DEBUG]-[org.mybatis.spring.transaction.SpringManagedTransaction] JDBC Connection [com.dangdang.ddframe.rdb.sharding.jdbc.ShardingConnection@58e6b9bc] will not be managed by Spring
- 2016-10-28 17:20:15 [DEBUG]-[com.mjkf.demo.mapper.UserMapper.select] ==> Preparing: SELECT ID,USER_ID,NAME,AGE FROM t_user WHERE USER_ID = ?
- 2016-10-28 17:20:15 [DEBUG]-[com.mjkf.demo.mapper.UserMapper.select] ==> Parameters: 1(Integer)
- 2016-10-28 17:20:15 [DEBUG]-[com.dangdang.ddframe.rdb.sharding.parser.SQLParserFactory] Logic SQL: SELECT ID,USER_ID,NAME,AGE FROM t_user WHERE USER_ID = ?
- 2016-10-28 17:20:15 [DEBUG]-[com.dangdang.ddframe.rdb.sharding.parser.SQLParseEngine] Parsed SQL result: SQLParsedResult(routeContext=RouteContext(tables=[Table(name=t_user, alias=Optional.absent())], sqlStatementType=null, sqlBuilder=null), conditionContexts=[ConditionContext(conditions={Condition.Column(columnName=USER_ID, tableName=t_user)=Condition(column=Condition.Column(columnName=USER_ID, tableName=t_user), operator==, values=[1], valueIndices=[0])})], mergeContext=MergeContext(orderByColumns=[], groupByColumns=[], aggregationColumns=[], limit=null))
- 2016-10-28 17:20:15 [DEBUG]-[com.dangdang.ddframe.rdb.sharding.parser.SQLParseEngine] Parsed SQL: SELECT ID, USER_ID, NAME, AGE FROM [Token(t_user)] WHERE USER_ID = ?
- 2016-10-28 17:20:15 [DEBUG]-[com.dangdang.ddframe.rdb.sharding.router.SQLRouteEngine] final route result:[SQLExecutionUnit(dataSource=datasource_01, sql=SELECT ID, USER_ID, NAME, AGE FROM t_user_1 WHERE USER_ID = ?, sqlBuilder=SELECT ID, USER_ID, NAME, AGE FROM [Token(t_user_1)] WHERE USER_ID = ?)]
- 2016-10-28 17:20:15 [DEBUG]-[com.dangdang.ddframe.rdb.sharding.router.SQLRouteEngine] merge context:MergeContext(orderByColumns=[], groupByColumns=[], aggregationColumns=[], limit=null)
- 2016-10-28 17:20:15 [DEBUG]-[com.mjkf.demo.mapper.UserMapper.select] <== Total: 0
- 2016-10-28 17:20:15 [DEBUG]-[org.mybatis.spring.SqlSessionUtils] Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1c05239a]
- 2016-10-28 17:20:15 [DEBUG]-[org.springframework.jdbc.datasource.DataSourceUtils] Returning JDBC Connection to DataSource
- 0
- ======================分割线===========================
- 2016-10-28 17:20:15 [DEBUG]-[org.mybatis.spring.SqlSessionUtils] Creating a new SqlSession
- 2016-10-28 17:20:15 [DEBUG]-[org.mybatis.spring.SqlSessionUtils] SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@438c1676] was not registered for synchronization because synchronization is not active
- 2016-10-28 17:20:15 [DEBUG]-[org.springframework.jdbc.datasource.DataSourceUtils] Fetching JDBC Connection from DataSource
- 2016-10-28 17:20:15 [DEBUG]-[org.mybatis.spring.transaction.SpringManagedTransaction] JDBC Connection [com.dangdang.ddframe.rdb.sharding.jdbc.ShardingConnection@2216bf9f] will not be managed by Spring
- 2016-10-28 17:20:15 [DEBUG]-[com.mjkf.demo.mapper.UserMapper.selectAll] ==> Preparing: SELECT ID,USER_ID,NAME,AGE FROM t_user
- 2016-10-28 17:20:15 [DEBUG]-[com.mjkf.demo.mapper.UserMapper.selectAll] ==> Parameters:
- 2016-10-28 17:20:15 [DEBUG]-[com.dangdang.ddframe.rdb.sharding.parser.SQLParserFactory] Logic SQL: SELECT ID,USER_ID,NAME,AGE FROM t_user
- 2016-10-28 17:20:15 [DEBUG]-[com.dangdang.ddframe.rdb.sharding.parser.SQLParseEngine] Parsed SQL result: SQLParsedResult(routeContext=RouteContext(tables=[Table(name=t_user, alias=Optional.absent())], sqlStatementType=null, sqlBuilder=null), conditionContexts=[ConditionContext(conditions={})], mergeContext=MergeContext(orderByColumns=[], groupByColumns=[], aggregationColumns=[], limit=null))
- 2016-10-28 17:20:15 [DEBUG]-[com.dangdang.ddframe.rdb.sharding.parser.SQLParseEngine] Parsed SQL: SELECT ID, USER_ID, NAME, AGE FROM [Token(t_user)]
- 2016-10-28 17:20:15 [DEBUG]-[com.dangdang.ddframe.rdb.sharding.router.SQLRouteEngine] final route result:[SQLExecutionUnit(dataSource=datasource_01, sql=SELECT ID, USER_ID, NAME, AGE FROM t_user_0, sqlBuilder=SELECT ID, USER_ID, NAME, AGE FROM [Token(t_user_0)]), SQLExecutionUnit(dataSource=datasource_01, sql=SELECT ID, USER_ID, NAME, AGE FROM t_user_2, sqlBuilder=SELECT ID, USER_ID, NAME, AGE FROM [Token(t_user_2)]), SQLExecutionUnit(dataSource=datasource_01, sql=SELECT ID, USER_ID, NAME, AGE FROM t_user_1, sqlBuilder=SELECT ID, USER_ID, NAME, AGE FROM [Token(t_user_1)])]
- 2016-10-28 17:20:15 [DEBUG]-[com.dangdang.ddframe.rdb.sharding.router.SQLRouteEngine] merge context:MergeContext(orderByColumns=[], groupByColumns=[], aggregationColumns=[], limit=null)
- 2016-10-28 17:20:15 [DEBUG]-[com.dangdang.ddframe.rdb.sharding.merger.ShardingResultSets$WrapperResultSet] 747195039 join pipeline
- 2016-10-28 17:20:15 [DEBUG]-[com.dangdang.ddframe.rdb.sharding.merger.ShardingResultSets$WrapperResultSet] 1770136464 join pipeline
- 2016-10-28 17:20:15 [DEBUG]-[com.dangdang.ddframe.rdb.sharding.merger.ResultSetFactory] Sharding-JDBC: Sharding result sets type is 'MULTIPLE'
- 2016-10-28 17:20:15 [DEBUG]-[com.dangdang.ddframe.rdb.sharding.merger.pipeline.reducer.IteratorReducerResultSet] 1721468812 join pipeline
- 2016-10-28 17:20:15 [DEBUG]-[com.mjkf.demo.mapper.UserMapper.selectAll] <== Total: 10
- 2016-10-28 17:20:15 [DEBUG]-[org.mybatis.spring.SqlSessionUtils] Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@438c1676]
- 2016-10-28 17:20:15 [DEBUG]-[org.springframework.jdbc.datasource.DataSourceUtils] Returning JDBC Connection to DataSource
- 1002------->李四
- 1002------->李四
- 1002------->李四
- 1002------->李四
- 1001------->李四update2
- 1001------->李四update2
- 1001------->李四update2
- 1001------->李四update2
- 1001------->李四update2
- 1001------->李四update2
- 执行插入语句
- 2016-10-28 17:20:15 [DEBUG]-[org.mybatis.spring.SqlSessionUtils] Creating a new SqlSession
- 2016-10-28 17:20:15 [DEBUG]-[org.mybatis.spring.SqlSessionUtils] SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1e7ae447] was not registered for synchronization because synchronization is not active
- 2016-10-28 17:20:15 [DEBUG]-[org.springframework.jdbc.datasource.DataSourceUtils] Fetching JDBC Connection from DataSource
- 2016-10-28 17:20:15 [DEBUG]-[org.mybatis.spring.transaction.SpringManagedTransaction] JDBC Connection [com.dangdang.ddframe.rdb.sharding.jdbc.ShardingConnection@716acd11] will not be managed by Spring
- 2016-10-28 17:20:15 [DEBUG]-[com.mjkf.demo.mapper.UserMapper.insert] ==> Preparing: INSERT INTO t_user ( ID,USER_ID,NAME,AGE ) VALUES( ?,?,?,? )
- 2016-10-28 17:20:15 [DEBUG]-[com.mjkf.demo.mapper.UserMapper.insert] ==> Parameters: null, 1002(Integer), 李四(String), 18(Integer)
- 2016-10-28 17:20:15 [DEBUG]-[com.dangdang.ddframe.rdb.sharding.parser.SQLParserFactory] Logic SQL: INSERT INTO t_user ( ID,USER_ID,NAME,AGE ) VALUES( ?,?,?,? )
- 2016-10-28 17:20:15 [DEBUG]-[com.dangdang.ddframe.rdb.sharding.parser.SQLParseEngine] Parsed SQL result: SQLParsedResult(routeContext=RouteContext(tables=[Table(name=t_user, alias=Optional.absent())], sqlStatementType=null, sqlBuilder=null), conditionContexts=[ConditionContext(conditions={Condition.Column(columnName=USER_ID, tableName=t_user)=Condition(column=Condition.Column(columnName=USER_ID, tableName=t_user), operator==, values=[1002], valueIndices=[1])})], mergeContext=MergeContext(orderByColumns=[], groupByColumns=[], aggregationColumns=[], limit=null))
- 2016-10-28 17:20:15 [DEBUG]-[com.dangdang.ddframe.rdb.sharding.parser.SQLParseEngine] Parsed SQL: INSERT INTO [Token(t_user)] (ID, USER_ID, NAME, AGE) VALUES (?, ?, ?, ?)
- 2016-10-28 17:20:15 [DEBUG]-[com.dangdang.ddframe.rdb.sharding.router.SQLRouteEngine] final route result:[SQLExecutionUnit(dataSource=datasource_01, sql=INSERT INTO t_user_0 (ID, USER_ID, NAME, AGE) VALUES (?, ?, ?, ?), sqlBuilder=INSERT INTO [Token(t_user_0)] (ID, USER_ID, NAME, AGE) VALUES (?, ?, ?, ?))]
- 2016-10-28 17:20:15 [DEBUG]-[com.dangdang.ddframe.rdb.sharding.router.SQLRouteEngine] merge context:MergeContext(orderByColumns=[], groupByColumns=[], aggregationColumns=[], limit=null)
- 2016-10-28 17:20:15 [DEBUG]-[org.mybatis.spring.SqlSessionUtils] Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1e7ae447]
- 2016-10-28 17:20:15 [DEBUG]-[org.springframework.jdbc.datasource.DataSourceUtils] Returning JDBC Connection to DataSource
- ======================分割线===========================
- 执行更新语句
- 2016-10-28 17:20:15 [DEBUG]-[org.mybatis.spring.SqlSessionUtils] Creating a new SqlSession
- 2016-10-28 17:20:15 [DEBUG]-[org.mybatis.spring.SqlSessionUtils] SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@722ca338] was not registered for synchronization because synchronization is not active
- 2016-10-28 17:20:15 [DEBUG]-[org.springframework.jdbc.datasource.DataSourceUtils] Fetching JDBC Connection from DataSource
- 2016-10-28 17:20:15 [DEBUG]-[org.mybatis.spring.transaction.SpringManagedTransaction] JDBC Connection [com.dangdang.ddframe.rdb.sharding.jdbc.ShardingConnection@508fec17] will not be managed by Spring
- 2016-10-28 17:20:15 [DEBUG]-[com.mjkf.demo.mapper.UserMapper.updateByPrimaryKeySelective] ==> Preparing: UPDATE t_user SET USER_ID = ?,NAME = ?,AGE = ? WHERE ID = ?
- 2016-10-28 17:20:15 [DEBUG]-[com.mjkf.demo.mapper.UserMapper.updateByPrimaryKeySelective] ==> Parameters: 1001(Integer), 李四update(String), 18(Integer), 24(Integer)
- 2016-10-28 17:20:15 [DEBUG]-[com.dangdang.ddframe.rdb.sharding.parser.SQLParserFactory] Logic SQL: UPDATE t_user SET USER_ID = ?,NAME = ?,AGE = ? WHERE ID = ?
- 2016-10-28 17:20:15 [DEBUG]-[com.dangdang.ddframe.rdb.sharding.parser.SQLParseEngine] Parsed SQL result: SQLParsedResult(routeContext=RouteContext(tables=[Table(name=t_user, alias=Optional.absent())], sqlStatementType=null, sqlBuilder=null), conditionContexts=[ConditionContext(conditions={})], mergeContext=MergeContext(orderByColumns=[], groupByColumns=[], aggregationColumns=[], limit=null))
- 2016-10-28 17:20:15 [DEBUG]-[com.dangdang.ddframe.rdb.sharding.parser.SQLParseEngine] Parsed SQL: UPDATE [Token(t_user)] SET USER_ID = ?, NAME = ?, AGE = ? WHERE ID = ?
- 2016-10-28 17:20:15 [DEBUG]-[com.dangdang.ddframe.rdb.sharding.router.SQLRouteEngine] final route result:[SQLExecutionUnit(dataSource=datasource_01, sql=UPDATE t_user_0 SET USER_ID = ?, NAME = ?, AGE = ? WHERE ID = ?, sqlBuilder=UPDATE [Token(t_user_0)] SET USER_ID = ?, NAME = ?, AGE = ? WHERE ID = ?), SQLExecutionUnit(dataSource=datasource_01, sql=UPDATE t_user_1 SET USER_ID = ?, NAME = ?, AGE = ? WHERE ID = ?, sqlBuilder=UPDATE [Token(t_user_1)] SET USER_ID = ?, NAME = ?, AGE = ? WHERE ID = ?), SQLExecutionUnit(dataSource=datasource_01, sql=UPDATE t_user_2 SET USER_ID = ?, NAME = ?, AGE = ? WHERE ID = ?, sqlBuilder=UPDATE [Token(t_user_2)] SET USER_ID = ?, NAME = ?, AGE = ? WHERE ID = ?)]
- 2016-10-28 17:20:15 [DEBUG]-[com.dangdang.ddframe.rdb.sharding.router.SQLRouteEngine] merge context:MergeContext(orderByColumns=[], groupByColumns=[], aggregationColumns=[], limit=null)
- 2016-10-28 17:20:15 [DEBUG]-[org.mybatis.spring.SqlSessionUtils] Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@722ca338]
- 2016-10-28 17:20:15 [DEBUG]-[org.springframework.jdbc.datasource.DataSourceUtils] Returning JDBC Connection to DataSource
- ======================分割线===========================
- 2016-10-28 17:20:15 [DEBUG]-[org.springframework.jdbc.datasource.DataSourceTransactionManager] Creating new transaction with name [com.mjkf.demo.service.impl.UserServiceImpl.updateByExample]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
- 2016-10-28 17:20:15 [DEBUG]-[org.springframework.jdbc.datasource.DataSourceTransactionManager] Acquired Connection [com.dangdang.ddframe.rdb.sharding.jdbc.ShardingConnection@52ffd2a3] for JDBC transaction
- 2016-10-28 17:20:15 [DEBUG]-[org.springframework.jdbc.datasource.DataSourceTransactionManager] Switching JDBC Connection [com.dangdang.ddframe.rdb.sharding.jdbc.ShardingConnection@52ffd2a3] to manual commit
- 2016-10-28 17:20:15 [DEBUG]-[org.springframework.transaction.support.TransactionSynchronizationManager] Bound value [org.springframework.jdbc.datasource.ConnectionHolder@68c04a7c] for key [com.dangdang.ddframe.rdb.sharding.spring.datasource.SpringShardingDataSource@45ce43b9] to thread [main]
- 2016-10-28 17:20:15 [DEBUG]-[org.springframework.transaction.support.TransactionSynchronizationManager] Initializing transaction synchronization
- 2016-10-28 17:20:15 [DEBUG]-[org.springframework.transaction.interceptor.TransactionInterceptor] Getting transaction for [com.mjkf.demo.service.impl.UserServiceImpl.updateByExample]
- 2016-10-28 17:20:15 [DEBUG]-[org.mybatis.spring.SqlSessionUtils] Creating a new SqlSession
- 2016-10-28 17:20:15 [DEBUG]-[org.mybatis.spring.SqlSessionUtils] Registering transaction synchronization for SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@40595670]
- 2016-10-28 17:20:15 [DEBUG]-[org.springframework.transaction.support.TransactionSynchronizationManager] Bound value [org.mybatis.spring.SqlSessionHolder@2e1de495] for key [org.apache.ibatis.session.defaults.DefaultSqlSessionFactory@5adc783a] to thread [main]
- 2016-10-28 17:20:15 [DEBUG]-[org.springframework.transaction.support.TransactionSynchronizationManager] Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@68c04a7c] for key [com.dangdang.ddframe.rdb.sharding.spring.datasource.SpringShardingDataSource@45ce43b9] bound to thread [main]
- 2016-10-28 17:20:15 [DEBUG]-[org.springframework.transaction.support.TransactionSynchronizationManager] Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@68c04a7c] for key [com.dangdang.ddframe.rdb.sharding.spring.datasource.SpringShardingDataSource@45ce43b9] bound to thread [main]
- 2016-10-28 17:20:15 [DEBUG]-[org.mybatis.spring.transaction.SpringManagedTransaction] JDBC Connection [com.dangdang.ddframe.rdb.sharding.jdbc.ShardingConnection@52ffd2a3] will be managed by Spring
- 2016-10-28 17:20:15 [DEBUG]-[com.mjkf.demo.mapper.UserMapper.updateByExampleSelective] ==> Preparing: UPDATE t_user SET USER_ID = ?,NAME = ?,AGE = ? WHERE ( USER_iD = ? )
- 2016-10-28 17:20:15 [DEBUG]-[com.mjkf.demo.mapper.UserMapper.updateByExampleSelective] ==> Parameters: 1001(Integer), 李四update2(String), 19(Integer), 1001(Integer)
- 2016-10-28 17:20:15 [DEBUG]-[com.dangdang.ddframe.rdb.sharding.parser.SQLParserFactory] Logic SQL: UPDATE t_user SET USER_ID = ?,NAME = ?,AGE = ? WHERE ( USER_iD = ? )
- 2016-10-28 17:20:15 [DEBUG]-[com.dangdang.ddframe.rdb.sharding.parser.SQLParseEngine] Parsed SQL result: SQLParsedResult(routeContext=RouteContext(tables=[Table(name=t_user, alias=Optional.absent())], sqlStatementType=null, sqlBuilder=null), conditionContexts=[ConditionContext(conditions={})], mergeContext=MergeContext(orderByColumns=[], groupByColumns=[], aggregationColumns=[], limit=null))
- 2016-10-28 17:20:15 [DEBUG]-[com.dangdang.ddframe.rdb.sharding.parser.SQLParseEngine] Parsed SQL: UPDATE [Token(t_user)] SET USER_ID = ?, NAME = ?, AGE = ? WHERE USER_iD = ?
- 2016-10-28 17:20:15 [DEBUG]-[com.dangdang.ddframe.rdb.sharding.router.SQLRouteEngine] final route result:[SQLExecutionUnit(dataSource=datasource_01, sql=UPDATE t_user_2 SET USER_ID = ?, NAME = ?, AGE = ? WHERE USER_iD = ?, sqlBuilder=UPDATE [Token(t_user_2)] SET USER_ID = ?, NAME = ?, AGE = ? WHERE USER_iD = ?), SQLExecutionUnit(dataSource=datasource_01, sql=UPDATE t_user_0 SET USER_ID = ?, NAME = ?, AGE = ? WHERE USER_iD = ?, sqlBuilder=UPDATE [Token(t_user_0)] SET USER_ID = ?, NAME = ?, AGE = ? WHERE USER_iD = ?), SQLExecutionUnit(dataSource=datasource_01, sql=UPDATE t_user_1 SET USER_ID = ?, NAME = ?, AGE = ? WHERE USER_iD = ?, sqlBuilder=UPDATE [Token(t_user_1)] SET USER_ID = ?, NAME = ?, AGE = ? WHERE USER_iD = ?)]
- 2016-10-28 17:20:15 [DEBUG]-[com.dangdang.ddframe.rdb.sharding.router.SQLRouteEngine] merge context:MergeContext(orderByColumns=[], groupByColumns=[], aggregationColumns=[], limit=null)
- 2016-10-28 17:20:15 [DEBUG]-[org.springframework.transaction.support.TransactionSynchronizationManager] Retrieved value [org.mybatis.spring.SqlSessionHolder@2e1de495] for key [org.apache.ibatis.session.defaults.DefaultSqlSessionFactory@5adc783a] bound to thread [main]
- 2016-10-28 17:20:15 [DEBUG]-[org.springframework.transaction.support.TransactionSynchronizationManager] Retrieved value [org.mybatis.spring.SqlSessionHolder@2e1de495] for key [org.apache.ibatis.session.defaults.DefaultSqlSessionFactory@5adc783a] bound to thread [main]
- 2016-10-28 17:20:15 [DEBUG]-[org.mybatis.spring.SqlSessionUtils] Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@40595670]
- 2016-10-28 17:20:15 [DEBUG]-[org.springframework.transaction.interceptor.TransactionInterceptor] Completing transaction for [com.mjkf.demo.service.impl.UserServiceImpl.updateByExample]
- 2016-10-28 17:20:15 [DEBUG]-[org.springframework.jdbc.datasource.DataSourceTransactionManager] Triggering beforeCommit synchronization
- 2016-10-28 17:20:15 [DEBUG]-[org.mybatis.spring.SqlSessionUtils] Transaction synchronization committing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@40595670]
- 2016-10-28 17:20:16 [DEBUG]-[org.springframework.jdbc.datasource.DataSourceTransactionManager] Triggering beforeCompletion synchronization
- 2016-10-28 17:20:16 [DEBUG]-[org.mybatis.spring.SqlSessionUtils] Transaction synchronization deregistering SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@40595670]
- 2016-10-28 17:20:16 [DEBUG]-[org.springframework.transaction.support.TransactionSynchronizationManager] Removed value [org.mybatis.spring.SqlSessionHolder@2e1de495] for key [org.apache.ibatis.session.defaults.DefaultSqlSessionFactory@5adc783a] from thread [main]
- 2016-10-28 17:20:16 [DEBUG]-[org.mybatis.spring.SqlSessionUtils] Transaction synchronization closing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@40595670]
- 2016-10-28 17:20:16 [DEBUG]-[org.springframework.transaction.support.TransactionSynchronizationManager] Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@68c04a7c] for key [com.dangdang.ddframe.rdb.sharding.spring.datasource.SpringShardingDataSource@45ce43b9] bound to thread [main]
- 2016-10-28 17:20:16 [DEBUG]-[org.springframework.jdbc.datasource.DataSourceTransactionManager] Initiating transaction commit
- 2016-10-28 17:20:16 [DEBUG]-[org.springframework.jdbc.datasource.DataSourceTransactionManager] Committing JDBC transaction on Connection [com.dangdang.ddframe.rdb.sharding.jdbc.ShardingConnection@52ffd2a3]
- 2016-10-28 17:20:16 [DEBUG]-[org.springframework.jdbc.datasource.DataSourceTransactionManager] Triggering afterCommit synchronization
- 2016-10-28 17:20:16 [DEBUG]-[org.springframework.jdbc.datasource.DataSourceTransactionManager] Triggering afterCompletion synchronization
- 2016-10-28 17:20:16 [DEBUG]-[org.springframework.transaction.support.TransactionSynchronizationManager] Clearing transaction synchronization
- 2016-10-28 17:20:16 [DEBUG]-[org.springframework.transaction.support.TransactionSynchronizationManager] Removed value [org.springframework.jdbc.datasource.ConnectionHolder@68c04a7c] for key [com.dangdang.ddframe.rdb.sharding.spring.datasource.SpringShardingDataSource@45ce43b9] from thread [main]
- 2016-10-28 17:20:16 [DEBUG]-[org.springframework.jdbc.datasource.DataSourceUtils] Resetting read-only flag of JDBC Connection [com.dangdang.ddframe.rdb.sharding.jdbc.ShardingConnection@52ffd2a3]
- 2016-10-28 17:20:16 [DEBUG]-[org.springframework.jdbc.datasource.DataSourceTransactionManager] Releasing JDBC Connection [com.dangdang.ddframe.rdb.sharding.jdbc.ShardingConnection@52ffd2a3] after transaction
- 2016-10-28 17:20:16 [DEBUG]-[org.springframework.jdbc.datasource.DataSourceUtils] Returning JDBC Connection to DataSource
- 2016-10-28 17:20:16 [DEBUG]-[org.springframework.test.context.TestContextManager] afterTestMethod(): instance [test.mjkf.MainTest@5b0f7c0d], method [public void test.mjkf.MainTest.test()], exception [null]
- 2016-10-28 17:20:16 [DEBUG]-[org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener] After test method: context [DefaultTestContext@29ae5edf testClass = MainTest, testInstance = test.mjkf.MainTest@5b0f7c0d, testMethod = test@MainTest, testException = [null], mergedContextConfiguration = [MergedContextConfiguration@76d697d9 testClass = MainTest, locations = '{classpath*:spring/applicationContext.xml}', classes = '{}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{}', contextLoader = 'org.springframework.test.context.support.DelegatingSmartContextLoader', parent = [null]]], class annotated with @DirtiesContext [false] with mode [null], method annotated with @DirtiesContext [false] with mode [null].
- 2016-10-28 17:20:16 [DEBUG]-[org.springframework.test.context.TestContextManager] afterTestClass(): class [test.mjkf.MainTest]
- 2016-10-28 17:20:16 [DEBUG]-[org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener] After test class: context [DefaultTestContext@29ae5edf testClass = MainTest, testInstance = [null], testMethod = [null], testException = [null], mergedContextConfiguration = [MergedContextConfiguration@76d697d9 testClass = MainTest, locations = '{classpath*:spring/applicationContext.xml}', classes = '{}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{}', contextLoader = 'org.springframework.test.context.support.DelegatingSmartContextLoader', parent = [null]]], class annotated with @DirtiesContext [false] with mode [null].
- 2016-10-28 17:20:16 [INFO]-[org.springframework.context.support.GenericApplicationContext] Closing org.springframework.context.support.GenericApplicationContext@7d7c88d4: startup date [Fri Oct 28 17:20:13 CST 2016]; root of context hierarchy
- 2016-10-28 17:20:16 [DEBUG]-[org.springframework.context.support.GenericApplicationContext] Publishing event in org.springframework.context.support.GenericApplicationContext@7d7c88d4: org.springframework.context.event.ContextClosedEvent[source=org.springframework.context.support.GenericApplicationContext@7d7c88d4: startup date [Fri Oct 28 17:20:13 CST 2016]; root of context hierarchy]
- 2016-10-28 17:20:16 [DEBUG]-[org.springframework.beans.factory.support.DefaultListableBeanFactory] Returning cached instance of singleton bean 'sqlSessionFactory'
- 2016-10-28 17:20:16 [DEBUG]-[org.springframework.beans.factory.support.DefaultListableBeanFactory] Returning cached instance of singleton bean 'lifecycleProcessor'
- 2016-10-28 17:20:16 [DEBUG]-[org.springframework.beans.factory.support.DefaultListableBeanFactory] Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@45f0d31e: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,org.springframework.context.event.internalEventListenerProcessor,org.springframework.context.event.internalEventListenerFactory,userServiceImpl,emailServer,propertyConfigurer,dataSource_master,dataSource_slave,datasource_01,userTableStrategy,shardingDataSource,sqlSessionFactory,sqlSession,com.mjkf.framework.mybatis.spring.mapper.MapperScannerConfigurer#0,org.springframework.transaction.config.internalTransactionalEventListenerFactory,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,transactionManager,transactionAdvice,transactionPointCut,org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor,org.springframework.context.annotation.ConfigurationClassPostProcessor.enhancedConfigurationProcessor,userMapper]; root of factory hierarchy
- 2016-10-28 17:20:16 [DEBUG]-[org.springframework.beans.factory.support.DefaultListableBeanFactory] Retrieved dependent beans for bean '(inner bean)#a1848dc#1': [datasource_01]
- 2016-10-28 17:20:16 [DEBUG]-[org.springframework.beans.factory.support.DisposableBeanAdapter] Invoking destroy method 'close' on bean with name '(inner bean)#a1848dc#1'
- 2016-10-28 17:20:16 [DEBUG]-[org.springframework.beans.factory.support.DisposableBeanAdapter] Invoking destroy method 'close' on bean with name 'dataSource_slave'
- 2016-10-28 17:20:16 [DEBUG]-[org.springframework.beans.factory.support.DefaultListableBeanFactory] Retrieved dependent beans for bean 'userServiceImpl': [test.mjkf.MainTest]
- 2016-10-28 17:20:16 [DEBUG]-[org.springframework.beans.factory.support.DefaultListableBeanFactory] Retrieved dependent beans for bean '(inner bean)#213466fe': [transactionAdvice]
- 2016-10-28 17:20:16 [DEBUG]-[org.springframework.beans.factory.support.DefaultListableBeanFactory] Retrieved dependent beans for bean 'sqlSessionFactory': [sqlSession]
- 2016-10-28 17:20:16 [DEBUG]-[org.springframework.beans.factory.support.DefaultListableBeanFactory] Retrieved dependent beans for bean '(inner bean)#44b56ed9': [shardingDataSource]
- 2016-10-28 17:20:16 [DEBUG]-[org.springframework.beans.factory.support.DefaultListableBeanFactory] Retrieved dependent beans for bean '(inner bean)#1d04e75b': [(inner bean)#44b56ed9]
- 2016-10-28 17:20:16 [DEBUG]-[org.springframework.beans.factory.support.DefaultListableBeanFactory] Retrieved dependent beans for bean '(inner bean)#a1848dc': [(inner bean)#1d04e75b]
- 2016-10-28 17:20:16 [DEBUG]-[org.springframework.beans.factory.support.DisposableBeanAdapter] Invoking destroy method 'close' on bean with name '(inner bean)#a1848dc'
- 2016-10-28 17:20:16 [INFO]-[com.alibaba.druid.pool.DruidDataSource] {dataSource-2} closed
- 2016-10-28 17:20:16 [DEBUG]-[org.springframework.beans.factory.support.DisposableBeanAdapter] Invoking destroy method 'close' on bean with name 'dataSource_master'
- 2016-10-28 17:20:16 [INFO]-[com.alibaba.druid.pool.DruidDataSource] {dataSource-1} closed
这篇关于Mycat\atlas\sharding-jdbc的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!