merge:代码合并
This commit is contained in:
@@ -113,12 +113,12 @@
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.apache.shardingsphere</groupId>-->
|
||||
<!-- <artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>-->
|
||||
<!-- <version>5.1.1</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!--Spring boot 核心 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.shardingsphere</groupId>
|
||||
<artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
|
||||
<version>5.1.1</version>
|
||||
</dependency>
|
||||
<!-- Spring boot 核心 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
|
||||
@@ -10,7 +10,7 @@ import org.springframework.context.annotation.Primary;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
@Configuration
|
||||
//@Configuration
|
||||
@Slf4j
|
||||
public class DataBaseConfig {
|
||||
public static CountSqlParser countSqlParser = new CountSqlParser();
|
||||
|
||||
@@ -28,7 +28,7 @@ public class WQLCore {
|
||||
//解析wql文件的根目录
|
||||
public static String ROOT = "wql";
|
||||
//数据库默认名
|
||||
public static String defalutDBName = "dataSource";
|
||||
public static String defalutDBName = "shardingSphereDataSource";
|
||||
//wql源文件
|
||||
public static HashMap<String, ArrayList<String>> wqlMap = new HashMap<String, ArrayList<String>>();
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.apache.commons.beanutils.BasicDynaBean;
|
||||
import org.apache.commons.beanutils.BasicDynaClass;
|
||||
import org.apache.commons.beanutils.DynaProperty;
|
||||
import org.apache.commons.beanutils.RowSetDynaClass;
|
||||
import org.apache.shardingsphere.driver.jdbc.core.resultset.ShardingSphereResultSet;
|
||||
import org.nl.modules.wql.util.WqlUtil;
|
||||
|
||||
import java.beans.IntrospectionException;
|
||||
@@ -342,10 +343,10 @@ public class ResultBean implements Serializable, Cloneable {
|
||||
}
|
||||
try {
|
||||
//支持别名的设置
|
||||
// if (sqlResultSet instanceof ShardingSphereResultSet){
|
||||
// ShardingSphereResultSet resultSet = (ShardingSphereResultSet) sqlResultSet;
|
||||
// sqlResultSet = resultSet.getResultSets().get(0);
|
||||
// }
|
||||
if (sqlResultSet instanceof ShardingSphereResultSet){
|
||||
ShardingSphereResultSet resultSet = (ShardingSphereResultSet) sqlResultSet;
|
||||
sqlResultSet = resultSet.getResultSets().get(0);
|
||||
}
|
||||
|
||||
WQLRowSetDynaClass rs = new WQLRowSetDynaClass(sqlResultSet, true, -1);
|
||||
rslist.add(rs);
|
||||
|
||||
@@ -26,7 +26,7 @@ public class WQLObject implements Serializable, Cloneable {
|
||||
private static final long serialVersionUID = 3512111887957792224L;
|
||||
|
||||
|
||||
private String dbname = "dataSource"; //指定使用的数据库
|
||||
private String dbname = "shardingSphereDataSource"; //指定使用的数据库
|
||||
|
||||
public WQLObject setDbname(String dbname) {
|
||||
this.dbname = dbname;
|
||||
|
||||
@@ -47,7 +47,7 @@ public class WO implements Serializable, Cloneable {
|
||||
public WP wp;
|
||||
|
||||
private String code = ""; //当前交易编号
|
||||
private String dbname = "dataSource"; //指定使用的数据库
|
||||
private String dbname = "shardingSphereDataSource"; //指定使用的数据库
|
||||
|
||||
public WO setDbname(String dbname) {
|
||||
this.dbname = dbname;
|
||||
|
||||
@@ -480,7 +480,7 @@ public class ClassstandardServiceImpl implements ClassstandardService {
|
||||
|
||||
//添加子节点
|
||||
try {
|
||||
List<Entity> list = Db.use((DataSource) SpringContextHolder.getBean("dataSource")).query(sql);
|
||||
List<Entity> list = Db.use((DataSource) SpringContextHolder.getBean("shardingSphereDataSource")).query(sql);
|
||||
list.forEach(item -> {
|
||||
set.add(item.getStr("class_id"));
|
||||
});
|
||||
|
||||
@@ -2,56 +2,103 @@ server:
|
||||
port: 8013
|
||||
#配置数据源
|
||||
spring:
|
||||
datasource:
|
||||
druid:
|
||||
db-type: com.alibaba.druid.pool.DruidDataSource
|
||||
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
|
||||
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:lms}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
||||
username: ${DB_USER:root}
|
||||
password: ${DB_PWD:123456}
|
||||
# 初始连接数
|
||||
initial-size: 5
|
||||
# 最小连接数
|
||||
min-idle: 15
|
||||
# 最大连接数
|
||||
max-active: 30
|
||||
# 超时时间(以秒数为单位)
|
||||
remove-abandoned-timeout: 180
|
||||
# 获取连接超时时间
|
||||
max-wait: 3000
|
||||
# 连接有效性检测时间
|
||||
time-between-eviction-runs-millis: 60000
|
||||
# 连接在池中最小生存的时间
|
||||
min-evictable-idle-time-millis: 300000
|
||||
# 连接在池中最大生存的时间
|
||||
max-evictable-idle-time-millis: 900000
|
||||
# 指明连接是否被空闲连接回收器(如果有)进行检验.如果检测失败,则连接将被从池中去除
|
||||
test-while-idle: true
|
||||
# 指明是否在从池中取出连接前进行检验,如果检验失败, 则从池中去除连接并尝试取出另一个
|
||||
test-on-borrow: true
|
||||
# 是否在归还到池中前进行检验
|
||||
test-on-return: false
|
||||
# 检测连接是否有效
|
||||
validation-query: select 1
|
||||
# 配置监控统计
|
||||
webStatFilter:
|
||||
enabled: true
|
||||
stat-view-servlet:
|
||||
enabled: true
|
||||
url-pattern: /druid/*
|
||||
reset-enable: false
|
||||
filters:
|
||||
DruidFilter,stat
|
||||
# query-timeout: 1
|
||||
# stat:
|
||||
# enabled: true
|
||||
# # 记录慢SQL
|
||||
# log-slow-sql: true
|
||||
# slow-sql-millis: 1000
|
||||
# merge-sql: true
|
||||
# wall:
|
||||
# config:
|
||||
# multi-statement-allow: true
|
||||
shardingsphere:
|
||||
datasource:
|
||||
names: master,slave
|
||||
master:
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
# 初始连接数
|
||||
initial-size: 20
|
||||
# 最小连接数
|
||||
min-idle: 30
|
||||
# 最大连接数
|
||||
max-active: 300
|
||||
# 是否自动回收超时连接
|
||||
socket-timeout: 10
|
||||
query-time-out: 7
|
||||
transaction-query-timeout: 30
|
||||
# 获取连接超时时间
|
||||
max-wait: 4000
|
||||
# 连接有效性检测时间
|
||||
time-between-eviction-runs-millis: 60000
|
||||
# 连接在池中最小生存的时间
|
||||
min-evictable-idle-time-millis: 300000
|
||||
# 连接在池中最大生存的时间
|
||||
max-evictable-idle-time-millis: 900000
|
||||
# 指明连接是否被空闲连接回收器(如果有)进行检验.如果检测失败,则连接将被从池中去除
|
||||
test-while-idle: true
|
||||
# 指明是否在从池中取出连接前进行检验,如果检验失败, 则从池中去除连接并尝试取出另一个
|
||||
test-on-borrow: true
|
||||
# 是否在归还到池中前进行检验
|
||||
test-on-return: false
|
||||
# 检测连接是否有效
|
||||
validation-query: select 1
|
||||
# 配置监控统计
|
||||
webStatFilter:
|
||||
enabled: true
|
||||
stat-view-servlet:
|
||||
enabled: true
|
||||
url-pattern: /druid/*
|
||||
reset-enable: false
|
||||
filters:
|
||||
DruidFilter,stat
|
||||
url: jdbc:mysql://localhost:3306/lms_xc?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true
|
||||
username: root
|
||||
password: root
|
||||
slave:
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
# 初始连接数
|
||||
initial-size: 20
|
||||
# 最小连接数
|
||||
min-idle: 30
|
||||
# 最大连接数
|
||||
max-active: 300
|
||||
# 是否自动回收超时连接
|
||||
socket-timeout: 10
|
||||
query-time-out: 7
|
||||
transaction-query-timeout: 30
|
||||
# 获取连接超时时间
|
||||
max-wait: 4000
|
||||
# 连接有效性检测时间
|
||||
time-between-eviction-runs-millis: 60000
|
||||
# 连接在池中最小生存的时间
|
||||
min-evictable-idle-time-millis: 300000
|
||||
# 连接在池中最大生存的时间
|
||||
max-evictable-idle-time-millis: 900000
|
||||
# 指明连接是否被空闲连接回收器(如果有)进行检验.如果检测失败,则连接将被从池中去除
|
||||
test-while-idle: true
|
||||
# 指明是否在从池中取出连接前进行检验,如果检验失败, 则从池中去除连接并尝试取出另一个
|
||||
test-on-borrow: true
|
||||
# 是否在归还到池中前进行检验
|
||||
test-on-return: false
|
||||
# 检测连接是否有效
|
||||
validation-query: select 1
|
||||
# 配置监控统计
|
||||
webStatFilter:
|
||||
enabled: true
|
||||
stat-view-servlet:
|
||||
enabled: true
|
||||
url-pattern: /druid/*
|
||||
reset-enable: false
|
||||
filters:
|
||||
DruidFilter,stat
|
||||
url: jdbc:mysql://127.0.0.1:3306/lms_xc?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true
|
||||
username: root
|
||||
password: root
|
||||
rules:
|
||||
readwrite-splitting:
|
||||
data-sources:
|
||||
db:
|
||||
type: Static
|
||||
props:
|
||||
#接口有事务,读写分离不生效,默认全部使用主库
|
||||
write-data-source-name: master
|
||||
read-data-source-names: slave
|
||||
#负载均衡算法名称
|
||||
load-balancer-name: round-robin
|
||||
|
||||
redis:
|
||||
#数据库索引
|
||||
database: ${REDIS_DB:15}
|
||||
|
||||
Reference in New Issue
Block a user