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