main
黄海 6 months ago
parent 967d7caf7f
commit fd2864ecbb

@ -10,7 +10,7 @@ public class LingDianTask implements ITask {
@SneakyThrows
public void run() {
//如果是读取侧
if(Start.isMysql==1){
if(Start.DEPLOY_ID ==1){
ReadDataUtil.doAction();
}
}

@ -18,11 +18,11 @@ import java.io.File;
public class Start extends JFinalConfig {
public static int isMysql;
public static int DEPLOY_ID;//部署侧 1读取侧 2写入侧
public static void main(String[] args) {
PropKit.use("application.properties");
isMysql = Integer.parseInt(PropKit.get("isMysql"));
DEPLOY_ID = Integer.parseInt(PropKit.get("DEPLOY_ID"));
UndertowServer.create(Start.class, "undertow.properties").start();
}
@ -61,17 +61,15 @@ public class Start extends JFinalConfig {
@Override
public void configPlugin(Plugins me) {
String jdbcUrl, user, password, driverClassName;
if (isMysql == 1) {
jdbcUrl = PropKit.get("mysql.jdbcUrl");
user = PropKit.get("mysql.user");
password = PropKit.get("mysql.password");
driverClassName = PropKit.get("mysql.driverClassName");
String jdbcUrl, user, password, driverClassName=PropKit.get("driverClassName");
if (DEPLOY_ID == 1) {
jdbcUrl = PropKit.get("read.jdbcUrl");
user = PropKit.get("read.user");
password = PropKit.get("read.password");
} else {
jdbcUrl = PropKit.get("postgresql.jdbcUrl");
user = PropKit.get("postgresql.user");
password = PropKit.get("postgresql.password");
driverClassName = PropKit.get("postgresql.driverClassName");
jdbcUrl = PropKit.get("write.jdbcUrl");
user = PropKit.get("write.user");
password = PropKit.get("write.password");
}
HikariCpPlugin hp = new HikariCpPlugin(jdbcUrl, user, password, driverClassName);
hp.setConnectionTestQuery(this.connectionTestQuery);
@ -82,7 +80,7 @@ public class Start extends JFinalConfig {
me.add(hp);
ActiveRecordPlugin arp = new ActiveRecordPlugin(hp);
if (isMysql == 1) {
if (DEPLOY_ID == 1) {
arp.setDialect(new MysqlDialect());
} else {
arp.setDialect(new PostgreSqlDialect());
@ -129,7 +127,7 @@ public class Start extends JFinalConfig {
@Override
public void onStart() {
//打印 启动Logo
String logoFile = (isMysql == 1) ? "mysqlLogo.txt" : "postgresqlLogo.txt";
String logoFile = (DEPLOY_ID == 1) ? "readLogo.txt" : "writeLogo.txt";
String path = Start.class.getClassLoader().getResource(logoFile).getPath();
File file = new File(path);
System.out.println(FileUtil.readUtf8String(file));

@ -1,17 +1,18 @@
# Mysql数据库信息
mysql.driverClassName=com.mysql.cj.jdbc.Driver
mysql.user=root
mysql.password=Password123@mysql
mysql.jdbcUrl=jdbc:mysql://10.10.14.203:3306/dataease?rewriteBatchedStatements=true&useUnicode=true&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true&failOverReadOnly=false
# 数据库通用设置
driverClassName=com.mysql.cj.jdbc.Driver
# Postgresql数据库信息
postgresql.driverClassName=org.postgresql.Driver
postgresql.user=postgres
postgresql.password=DsideaL147258369
postgresql.jdbcUrl=jdbc:postgresql://10.10.14.71:5432/szjz_db?reWriteBatchedInserts=true
# 读取侧数据库信息
read.user=root
read.password=Password123@mysql
read.jdbcUrl=jdbc:mysql://10.10.14.203:3306/dataease?rewriteBatchedStatements=true&useUnicode=true&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true&failOverReadOnly=false
# 当前是读取方还是写入方
isMysql=1
# 写入侧数据库信息
write.user=root
write.password=Password123@mysql
write.jdbcUrl=jdbc:mysql://10.10.14.203:3306/HuangHai_Test?rewriteBatchedStatements=true&useUnicode=true&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true&failOverReadOnly=false
# 当前是读取方还是写入方 1:读取 2写入
DEPLOY_ID=1
# 华为云OBS配置
#OBS(华为云云存储)

@ -1,17 +1,18 @@
# Mysql数据库信息
mysql.driverClassName=com.mysql.cj.jdbc.Driver
mysql.user=root
mysql.password=Password123@mysql
mysql.jdbcUrl=jdbc:mysql://10.10.14.203:3306/dataease?rewriteBatchedStatements=true&useUnicode=true&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true&failOverReadOnly=false
# 数据库通用设置
driverClassName=com.mysql.cj.jdbc.Driver
# Postgresql数据库信息
postgresql.driverClassName=org.postgresql.Driver
postgresql.user=postgres
postgresql.password=DsideaL147258369
postgresql.jdbcUrl=jdbc:postgresql://10.10.14.71:5432/szjz_db?reWriteBatchedInserts=true
# 读取侧数据库信息
read.user=root
read.password=Password123@mysql
read.jdbcUrl=jdbc:mysql://10.10.14.203:3306/dataease?rewriteBatchedStatements=true&useUnicode=true&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true&failOverReadOnly=false
# 当前是读取方还是写入方
isMysql=1
# 写入侧数据库信息
write.user=root
write.password=Password123@mysql
write.jdbcUrl=jdbc:mysql://10.10.14.203:3306/HuangHai_Test?rewriteBatchedStatements=true&useUnicode=true&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true&failOverReadOnly=false
# 当前是读取方还是写入方 1:读取 2写入
DEPLOY_ID=1
# 华为云OBS配置
#OBS(华为云云存储)

Loading…
Cancel
Save