数据库连接池配置项目
前提:使用这个数据库连接池配置项目的项目必须已经升级到spring boot 1.4.6.RELEASE和spring cloud Camden.SR7
1.此前数据库连接池中只有三个属性是可配置的url, username, password, 在数据库连接池配置项目中增加了更多的配置属性, 这些新增加的配置属性都是可选的, 列表如下
//必须配置的属性 url=jdbc:mysql://192.181.2.11:3306/tm_user username=qqqq password=12qwaszx //可选的配置属性, 等号右边是默认值 driverClassName=com.mysql.jdbc.Driver initialSize=5 maxActive=300 maxIdle=20 minIdle=5 maxWait=60000 removeAbandonedTimeout=180 removeAbandoned=true testOnBorrow=true testOnReturn=true testOnConnect=true testWhileIdle=true validationQuery=SELECT 1 timeBetweenEvictionRunsMillis=5000 jdbcInterceptors=ConnectionState;StatementFinalizer
2. 数据库的配置支持读写分离数据库, 可以配置一个写库和一个或多个读库, 写库的配置属性前缀为db.master,
读库最多可以配置5个, 前缀分别为db.slave, db.slave1, db.slave2, db.slave3, db.slave4, 下面的例子配置了一个写库和两个读库
# db config db.master.driverClassName=com.mysql.jdbc.Driver db.master.url=jdbc:mysql://191.168.1.1:3306/tm_user db.master.username=root db.master.password=1QAZ2wsx db.master.initialSize=5 db.master.maxActive=300 db.master.maxIdle=20 db.master.minIdle=5 db.master.maxWait=60000 db.master.removeAbandonedTimeout=180 db.master.removeAbandoned=true db.master.testOnBorrow=true db.master.testOnReturn=true db.master.testOnConnect=true db.master.testWhileIdle=true db.master.validationQuery=SELECT 1 db.master.timeBetweenEvictionRunsMillis=5000 db.master.jdbcInterceptors=ConnectionState;StatementFinalizer db.slave.driverClassName=com.mysql.jdbc.Driver db.slave.url=jdbc:mysql://10.1.2.13:3306/tm_user db.slave.username=root db.slave.password=1QAZ2wsx db.slave.initialSize=15 db.slave.maxActive=300 db.slave.maxIdle=20 db.slave.minIdle=5 db.slave.maxWait=60000 db.slave.removeAbandonedTimeout=180 db.slave.removeAbandoned=true db.slave.testOnBorrow=true db.slave.testOnReturn=true db.slave.testOnConnect=true db.slave.testWhileIdle=true db.slave.validationQuery=SELECT 1 db.slave.timeBetweenEvictionRunsMillis=5000 db.slave.jdbcInterceptors =ConnectionState;StatementFinalizer db.slave1.driverClassName=com.mysql.jdbc.Driver db.slave1.url=jdbc:mysql://10.1.2.13:3306/tm_user db.slave1.username=root db.slave1.password=1QAZ2wsx db.slave1.initialSize=25 db.slave1.maxActive=300 db.slave1.maxIdle=20 db.slave1.minIdle=5 db.slave1.maxWait=60000 db.slave1.removeAbandonedTimeout=180 db.slave1.removeAbandoned=true db.slave1.testOnBorrow=true db.slave1.testOnReturn=true db.slave1.testOnConnect=true db.slave1.testWhileIdle=true db.slave1.validationQuery=SELECT 1 db.slave1.timeBetweenEvictionRunsMillis=5000 db.slave1.jdbcInterceptors =ConnectionState;StatementFinalizer
------------------------- A little Progress a day makes you a big success... ----------------------------