|
|
|
@ -120,31 +120,26 @@ public class BaseApplication extends JFinalConfig {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void configPlugin(Plugins me) {
|
|
|
|
|
HikariCpPlugin masterPlugin = new HikariCpPlugin(PropKit.get("mysql.jdbcUrl"), PropKit.get("mysql.user"),
|
|
|
|
|
PropKit.get("mysql.password").trim(), PropKit.get("mysql.driverClassName"));
|
|
|
|
|
masterPlugin.setConnectionTestQuery(connectionTestQuery);
|
|
|
|
|
masterPlugin.setConnectionTimeout(connectionTimeoutMs);
|
|
|
|
|
masterPlugin.setIdleTimeout(idleTimeoutMs);
|
|
|
|
|
masterPlugin.setMaxLifetime(maxLifetimeMs);
|
|
|
|
|
masterPlugin.setMaximumPoolSize(maxPoolSize);
|
|
|
|
|
|
|
|
|
|
String jdbcUrlSlave = PropKit.get("mysql.jdbcUrlSlave");
|
|
|
|
|
if (StrKit.isBlank(jdbcUrlSlave)) jdbcUrlSlave = PropKit.get("mysql.jdbcUrl");
|
|
|
|
|
HikariCpPlugin slavePlugin = new HikariCpPlugin(jdbcUrlSlave, PropKit.get("mysql.user"),
|
|
|
|
|
PropKit.get("mysql.password").trim(), PropKit.get("mysql.driverClassName"));
|
|
|
|
|
slavePlugin.setConnectionTestQuery(connectionTestQuery);
|
|
|
|
|
slavePlugin.setConnectionTimeout(connectionTimeoutMs);
|
|
|
|
|
slavePlugin.setIdleTimeout(idleTimeoutMs);
|
|
|
|
|
slavePlugin.setMaxLifetime(maxLifetimeMs);
|
|
|
|
|
slavePlugin.setMaximumPoolSize(maxPoolSize);
|
|
|
|
|
me.add(masterPlugin);
|
|
|
|
|
me.add(slavePlugin);
|
|
|
|
|
String jdbcUrl = PropKit.get("mysql.jdbcUrl");
|
|
|
|
|
String user = PropKit.get("mysql.user");
|
|
|
|
|
String password = PropKit.get("mysql.password");
|
|
|
|
|
String driverClassName = PropKit.get("mysql.driverClassName");
|
|
|
|
|
HikariCpPlugin dsDbPlugin = new HikariCpPlugin(jdbcUrl, user, password, driverClassName);
|
|
|
|
|
dsDbPlugin.setConnectionTestQuery(connectionTestQuery);
|
|
|
|
|
dsDbPlugin.setConnectionTimeout(connectionTimeoutMs);
|
|
|
|
|
dsDbPlugin.setIdleTimeout(idleTimeoutMs);
|
|
|
|
|
dsDbPlugin.setMaxLifetime(maxLifetimeMs);
|
|
|
|
|
dsDbPlugin.setMaximumPoolSize(maxPoolSize);
|
|
|
|
|
me.add(dsDbPlugin);
|
|
|
|
|
HikariCpPlugin yltPlugin = new HikariCpPlugin(jdbcUrl.replace("/ds_db?", "/yltcharge?"), user, password, driverClassName);
|
|
|
|
|
me.add(yltPlugin);
|
|
|
|
|
|
|
|
|
|
// 配置ActiveRecord插件
|
|
|
|
|
ActiveRecordPlugin masterArp = new ActiveRecordPlugin("master", masterPlugin);
|
|
|
|
|
masterArp.setDialect(new MysqlDialect());
|
|
|
|
|
ActiveRecordPlugin slaveArp = new ActiveRecordPlugin("slave", slavePlugin);
|
|
|
|
|
slaveArp.setDialect(new MysqlDialect());
|
|
|
|
|
ActiveRecordPlugin arp = new ActiveRecordPlugin(dsDbPlugin);
|
|
|
|
|
arp.setDialect(new MysqlDialect());
|
|
|
|
|
|
|
|
|
|
ActiveRecordPlugin yltArp = new ActiveRecordPlugin("ylt", yltPlugin);
|
|
|
|
|
yltArp.setDialect(new MysqlDialect());
|
|
|
|
|
|
|
|
|
|
//遍历sql目录下所有的sql文件
|
|
|
|
|
File sqlDir;
|
|
|
|
@ -154,13 +149,13 @@ public class BaseApplication extends JFinalConfig {
|
|
|
|
|
for (File sqlFile : sqlFiles != null ? sqlFiles : new File[0]) {
|
|
|
|
|
//只加载.sql文件
|
|
|
|
|
if (sqlFile.getName().indexOf(".sql") > 0) {
|
|
|
|
|
masterArp.addSqlTemplate("/Sql/" + sqlFile.getName());
|
|
|
|
|
slaveArp.addSqlTemplate("/Sql/" + sqlFile.getName());
|
|
|
|
|
arp.addSqlTemplate("/Sql/" + sqlFile.getName());
|
|
|
|
|
yltArp.addSqlTemplate("/Sql/" + sqlFile.getName());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//加载
|
|
|
|
|
me.add(masterArp);
|
|
|
|
|
me.add(slaveArp);
|
|
|
|
|
me.add(arp);
|
|
|
|
|
me.add(yltArp);
|
|
|
|
|
// 用于缓存模块的redis服务
|
|
|
|
|
RedisPlugin redis = new RedisPlugin("Redis", PropKit.get("redis.ip"), PropKit.getInt("redis.port"), 10 * 1000, PropKit.get("redis.password"));
|
|
|
|
|
//启动redis组件
|
|
|
|
|