This is an automated email from the ASF dual-hosted git repository.
benjobs pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampark.git
The following commit(s) were added to refs/heads/dev by this push:
new dd6a96fd6 [Feat] sync h2 dialect improvement from dev-2.1.5 (#3765)
dd6a96fd6 is described below
commit dd6a96fd6d3a8ee57ee3ced2138b0485bb15016b
Author: benjobs <[email protected]>
AuthorDate: Mon Jun 17 04:28:43 2024 +0800
[Feat] sync h2 dialect improvement from dev-2.1.5 (#3765)
Co-authored-by: benjobs <[email protected]>
---
.../src/main/assembly/conf/config.yaml | 5 ++--
.../src/main/assembly/script/data/mysql-data.sql | 2 +-
.../console/base/config/SpringProperties.java | 32 ++++++++++++++++++----
.../console/system/authentication/ShiroConfig.java | 1 +
4 files changed, 31 insertions(+), 9 deletions(-)
diff --git
a/streampark-console/streampark-console-service/src/main/assembly/conf/config.yaml
b/streampark-console/streampark-console-service/src/main/assembly/conf/config.yaml
index e97991827..eec543398 100644
---
a/streampark-console/streampark-console-service/src/main/assembly/conf/config.yaml
+++
b/streampark-console/streampark-console-service/src/main/assembly/conf/config.yaml
@@ -35,10 +35,11 @@ server:
# system database, default h2, mysql|pgsql|h2
datasource:
dialect: h2 #h2, mysql, pgsql
+ h2-data-dir: ~/streampark/h2-data # if datasource.dialect is h2, you can
configure the data dir
# if datasource.dialect is mysql or pgsql, you need to configure the
following connection information
- # mysql/postgresql connect user
+ # mysql/postgresql/h2 connect user
username:
- # mysql/postgresql connect password
+ # mysql/postgresql/h2 connect password
password:
# mysql/postgresql connect jdbcURL
# mysql example: datasource.url:
jdbc:mysql://localhost:3306/streampark?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8
diff --git
a/streampark-console/streampark-console-service/src/main/assembly/script/data/mysql-data.sql
b/streampark-console/streampark-console-service/src/main/assembly/script/data/mysql-data.sql
index 545eba708..663831096 100644
---
a/streampark-console/streampark-console-service/src/main/assembly/script/data/mysql-data.sql
+++
b/streampark-console/streampark-console-service/src/main/assembly/script/data/mysql-data.sql
@@ -293,7 +293,7 @@ insert into `t_setting` values (15, 'ingress.mode.default',
null, 'Ingress domai
-- ----------------------------
-- Records of t_user
-- ----------------------------
-insert into `t_user` values (100000, 'admin', '',
'rh8b1ojwog777yrg0daesf04gk',
'2513f3748847298ea324dffbf67fe68681dd92315bda830065facd8efe08f54f', null, 1, 0,
null, '1', now(), now(),null,0,null,null);
+insert into `t_user` values (100000, 'admin', '',
'rh8b1ojwog777yrg0daesf04gk',
'2513f3748847298ea324dffbf67fe68681dd92315bda830065facd8efe08f54f', null, 1, 0,
100000, '1', now(), now(),null,0,null,null);
-- ----------------------------
-- Records of t_member
diff --git
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/config/SpringProperties.java
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/config/SpringProperties.java
index ecba4701d..9df6d2810 100644
---
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/config/SpringProperties.java
+++
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/config/SpringProperties.java
@@ -73,17 +73,37 @@ public class SpringProperties {
springConfig.put("spring.datasource.driver-class-name",
"org.postgresql.Driver");
break;
case "h2":
- springConfig.put("spring.datasource.driver-class-name",
"org.h2.Driver");
- springConfig.put("spring.datasource.username", "sa");
- springConfig.put("spring.datasource.password", "sa");
+ String h2DataDir = userConfig.getProperty("datasource.h2-data-dir",
null);
+ if (StringUtils.isBlank(h2DataDir)) {
+ h2DataDir = System.getProperty("user.home", "~") +
"/streampark/h2-data/metadata";
+ } else {
+ h2DataDir += h2DataDir.endsWith("/") ? "metadata" : "/metadata";
+ }
+
springConfig.put(
"spring.datasource.url",
-
"jdbc:h2:mem:streampark;MODE=MySQL;DB_CLOSE_DELAY=-1;DATABASE_TO_LOWER=true;INIT=runscript
from 'classpath:db/schema-h2.sql'");
+ String.format(
+
"jdbc:h2:file:%s;MODE=MySQL;DB_CLOSE_DELAY=-1;DATABASE_TO_LOWER=true;INIT=runscript
from 'classpath:db/schema-h2.sql'",
+ h2DataDir));
+
+ String userName = userConfig.getProperty("spring.datasource.username",
"admin");
+ String password = userConfig.getProperty("spring.datasource.password",
"streampark");
+
+ springConfig.put("spring.jpa.database-platform",
"org.hibernate.dialect.H2Dialect");
+ springConfig.put("spring.datasource.driver-class-name",
"org.h2.Driver");
+ springConfig.put("spring.datasource.username", userName);
+ springConfig.put("spring.datasource.password", password);
springConfig.put("spring.sql.init.data-locations",
"classpath:db/data-h2.sql");
springConfig.put("spring.sql.init.continue-on-error", "true");
- springConfig.put("spring.sql.init.username", "sa");
- springConfig.put("spring.sql.init.password", "sa");
+ springConfig.put("spring.sql.init.username", userName);
+ springConfig.put("spring.sql.init.password", password);
springConfig.put("spring.sql.init.mode", "always");
+
+ // h2
+ springConfig.put("spring.h2.console.path", "/h2-console");
+ springConfig.put("spring.h2.console.enabled", true);
+ springConfig.put("spring.h2.console.settings.web-allow-others", true);
+ springConfig.put("spring.h2.console.settings.trace", true);
break;
default:
throw new UnsupportedOperationException("Unsupported datasource
dialect: " + dialect);
diff --git
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/authentication/ShiroConfig.java
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/authentication/ShiroConfig.java
index 3384723ae..2b14903c3 100644
---
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/authentication/ShiroConfig.java
+++
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/authentication/ShiroConfig.java
@@ -43,6 +43,7 @@ public class ShiroConfig {
LinkedHashMap<String, String> filterChainDefinitionMap = new
LinkedHashMap<>();
filterChainDefinitionMap.put("/actuator/**", "anon");
+ filterChainDefinitionMap.put("/h2-console/**", "anon");
filterChainDefinitionMap.put("/doc.html", "anon");
filterChainDefinitionMap.put("/swagger-ui.html", "anon");