diff --git a/YunXiaoTools/src/main/java/com/dsideal/YunXiaoTools/Cron4j/LingDianTask.java b/YunXiaoTools/src/main/java/com/dsideal/YunXiaoTools/Cron4j/LingDianTask.java index e6330790..0ebe0317 100644 --- a/YunXiaoTools/src/main/java/com/dsideal/YunXiaoTools/Cron4j/LingDianTask.java +++ b/YunXiaoTools/src/main/java/com/dsideal/YunXiaoTools/Cron4j/LingDianTask.java @@ -10,7 +10,7 @@ public class LingDianTask implements ITask { @SneakyThrows public void run() { //如果是读取侧 - if(Start.isMysql==1){ + if(Start.DEPLOY_ID ==1){ ReadDataUtil.doAction(); } } diff --git a/YunXiaoTools/src/main/java/com/dsideal/YunXiaoTools/Start.java b/YunXiaoTools/src/main/java/com/dsideal/YunXiaoTools/Start.java index a3004921..23d4704f 100644 --- a/YunXiaoTools/src/main/java/com/dsideal/YunXiaoTools/Start.java +++ b/YunXiaoTools/src/main/java/com/dsideal/YunXiaoTools/Start.java @@ -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)); diff --git a/YunXiaoTools/src/main/resources/application.properties b/YunXiaoTools/src/main/resources/application.properties index 098199a1..035b1a5a 100644 --- a/YunXiaoTools/src/main/resources/application.properties +++ b/YunXiaoTools/src/main/resources/application.properties @@ -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(华为云云存储) diff --git a/YunXiaoTools/src/main/resources/mysqlLogo.txt b/YunXiaoTools/src/main/resources/readLogo.txt similarity index 100% rename from YunXiaoTools/src/main/resources/mysqlLogo.txt rename to YunXiaoTools/src/main/resources/readLogo.txt diff --git a/YunXiaoTools/src/main/resources/postgresqlLogo.txt b/YunXiaoTools/src/main/resources/writeLogo.txt similarity index 100% rename from YunXiaoTools/src/main/resources/postgresqlLogo.txt rename to YunXiaoTools/src/main/resources/writeLogo.txt diff --git a/YunXiaoTools/target/classes/application.properties b/YunXiaoTools/target/classes/application.properties index 098199a1..035b1a5a 100644 --- a/YunXiaoTools/target/classes/application.properties +++ b/YunXiaoTools/target/classes/application.properties @@ -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(华为云云存储) diff --git a/YunXiaoTools/target/classes/mysqlLogo.txt b/YunXiaoTools/target/classes/readLogo.txt similarity index 100% rename from YunXiaoTools/target/classes/mysqlLogo.txt rename to YunXiaoTools/target/classes/readLogo.txt diff --git a/YunXiaoTools/target/classes/postgresqlLogo.txt b/YunXiaoTools/target/classes/writeLogo.txt similarity index 100% rename from YunXiaoTools/target/classes/postgresqlLogo.txt rename to YunXiaoTools/target/classes/writeLogo.txt