diff --git a/broker/config/wildfirechat.conf b/broker/config/wildfirechat.conf index 913ec7f6..16d93c0a 100755 --- a/broker/config/wildfirechat.conf +++ b/broker/config/wildfirechat.conf @@ -42,6 +42,9 @@ embed.db 1 ## 使用mongodb时次开关无效(因为mongodb设置了消息过期时间,会自动清理,仅专业版支持mongodb)。 db.auto_clean_history_messages true +## h2db数据库的路径,默认为程序目录下的,可以指定其他目录。如果使用MySQL,可以忽略此配置 +h2db.path ./h2db/wfchat + ##服务器管理接口密钥。如果修改此端口需要同步修改使用管理API的地方,比如应用服务。 http.admin.secret_key 123456 diff --git a/broker/src/main/java/io/moquette/BrokerConstants.java b/broker/src/main/java/io/moquette/BrokerConstants.java index eed919cb..e25ee747 100755 --- a/broker/src/main/java/io/moquette/BrokerConstants.java +++ b/broker/src/main/java/io/moquette/BrokerConstants.java @@ -112,6 +112,8 @@ public final class BrokerConstants { public static final String EMBED_DB_PROPERTY_NAME = "embed.db"; public static final String DB_AUTO_CLEAN_HISTORY_MESSAGES = "db.auto_clean_history_messages"; + public static final String H2DB_PATH = "h2db.path"; + public static final String SENSITIVE_Filter_Type = "sensitive.filter.type"; diff --git a/broker/src/main/java/win/liyufan/im/DBUtil.java b/broker/src/main/java/win/liyufan/im/DBUtil.java index 4d448bed..3cbaf8dd 100755 --- a/broker/src/main/java/win/liyufan/im/DBUtil.java +++ b/broker/src/main/java/win/liyufan/im/DBUtil.java @@ -49,6 +49,7 @@ public class DBUtil { public static void init(IConfig config) { String embedDB = config.getProperty(BrokerConstants.EMBED_DB_PROPERTY_NAME); + String h2dbPath = config.getProperty(BrokerConstants.H2DB_PATH, "./h2db/wfchat"); boolean autoCleanMsgs = "true".equals(config.getProperty(BrokerConstants.DB_AUTO_CLEAN_HISTORY_MESSAGES)); if (embedDB != null && embedDB.equals("1")) { IsEmbedDB = true; @@ -67,7 +68,7 @@ public class DBUtil { migrateLocation = "filesystem:./migrate/h2"; comboPooledDataSource = new ComboPooledDataSource(); - comboPooledDataSource.setJdbcUrl( "jdbc:h2:./h2db/wfchat;AUTO_SERVER=TRUE;MODE=MySQL" ); + comboPooledDataSource.setJdbcUrl( "jdbc:h2:" + h2dbPath + ";AUTO_SERVER=TRUE;MODE=MySQL" ); comboPooledDataSource.setUser("SA"); comboPooledDataSource.setPassword("SA"); comboPooledDataSource.setMinPoolSize(5); diff --git a/distribution/src/main/resources/wildfirechat.conf b/distribution/src/main/resources/wildfirechat.conf index 4c3dc346..565ec57d 100755 --- a/distribution/src/main/resources/wildfirechat.conf +++ b/distribution/src/main/resources/wildfirechat.conf @@ -40,6 +40,9 @@ embed.db 1 ## 使用mongodb时次开关无效(因为mongodb设置了消息过期时间,会自动清理,仅专业版支持mongodb)。 db.auto_clean_history_messages true +## h2db数据库的路径,默认为程序目录下的,可以指定其他目录。如果使用MySQL,可以忽略此配置 +h2db.path ./h2db/wfchat + ##服务器管理接口密钥。如果修改此端口需要同步修改使用管理API的地方,比如应用服务。 http.admin.secret_key 123456