From 7b4b97569b103ae849ae97335356ec3aea0ac6ae Mon Sep 17 00:00:00 2001
From: xiongxiaoyang <1179705413@qq.com>
Date: Thu, 21 Dec 2023 12:04:48 +0800
Subject: [PATCH] =?UTF-8?q?fix:=20=E5=88=86=E5=BA=93=E5=88=86=E8=A1=A8?=
=?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=A4=B1=E6=95=88?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
shardingsphere-jdbc-core-spring-boot-starter 依赖版本过低
---
pom.xml | 7 +++++-
.../config/ShardingSphereConfiguration.java | 24 +++++++++++++++++++
...itional-spring-configuration-metadata.json | 6 +++++
src/main/resources/application.yml | 15 ++++++------
4 files changed, 44 insertions(+), 8 deletions(-)
create mode 100644 src/main/java/io/github/xxyopen/novel/core/config/ShardingSphereConfiguration.java
diff --git a/pom.xml b/pom.xml
index d01f740..99b1b9c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@
8.2.0
2.3.1
1.8.4
- 5.1.1
+ 5.2.1
3.19.1
3.0.0-M1
2.0.0
@@ -149,6 +149,11 @@
shardingsphere-jdbc-core-spring-boot-starter
${shardingsphere-jdbc.version}
+
+ com.h2database
+ h2
+ runtime
+
diff --git a/src/main/java/io/github/xxyopen/novel/core/config/ShardingSphereConfiguration.java b/src/main/java/io/github/xxyopen/novel/core/config/ShardingSphereConfiguration.java
new file mode 100644
index 0000000..ec465ef
--- /dev/null
+++ b/src/main/java/io/github/xxyopen/novel/core/config/ShardingSphereConfiguration.java
@@ -0,0 +1,24 @@
+package io.github.xxyopen.novel.core.config;
+
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * ShardingSphere 配置类,控制是否开启 ShardingSphere
+ *
+ * @author xiongxiaoyang
+ * @date 2023/12/21
+ */
+@Configuration
+@EnableAutoConfiguration(exclude = {
+ org.apache.shardingsphere.spring.boot.ShardingSphereAutoConfiguration.class
+})
+@ConditionalOnProperty(
+ prefix = "spring.shardingsphere",
+ name = {"enabled"},
+ havingValue = "false"
+)
+public class ShardingSphereConfiguration {
+
+}
diff --git a/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/src/main/resources/META-INF/additional-spring-configuration-metadata.json
index d74c6a7..bdcd71d 100644
--- a/src/main/resources/META-INF/additional-spring-configuration-metadata.json
+++ b/src/main/resources/META-INF/additional-spring-configuration-metadata.json
@@ -65,6 +65,12 @@
"name": "spring.elasticsearch.ssl.verification-mode",
"type": "java.lang.String",
"description": "设置 ssl 的认证模式,如果该配置项为 none ,说明不需要认证,信任所有的 ssl 证书."
+ },
+ {
+ "defaultValue": true,
+ "name": "spring.shardingsphere.enabled",
+ "description": "Whether enable shardingsphere or not.",
+ "type": "java.lang.Boolean"
}
]
}
\ No newline at end of file
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 946e0d0..75f3bd0 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -39,14 +39,15 @@ spring:
mode:
# 单机模式
type: Standalone
+ # 元数据持久化
repository:
- # 文件持久化
- type: File
+ # 数据库持久化
+ type: JDBC
props:
- # 元数据存储路径
- path: .shardingsphere
- # 使用本地配置覆盖持久化配置
- overwrite: true
+ # 元数据存储类型
+ provider: H2
+ jdbc_url: jdbc:h2:./.h2/shardingsphere
+
# 数据源配置
datasource:
names: ds_0
@@ -87,7 +88,7 @@ spring:
redis:
host: 127.0.0.1
port: 6379
- password: 123456
+ password: test123456
# Elasticsearch 配置
elasticsearch: