|
|
|
@ -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));
|
|
|
|
|