fix: 分库分表功能失效

shardingsphere-jdbc-core-spring-boot-starter 依赖版本过低
This commit is contained in:
xiongxiaoyang 2023-12-21 12:04:48 +08:00
parent 2270072d7e
commit 7b4b97569b
4 changed files with 44 additions and 8 deletions

View File

@ -22,7 +22,7 @@
<elasticsearch.version>8.2.0</elasticsearch.version>
<xxl-job.version>2.3.1</xxl-job.version>
<sentinel.version>1.8.4</sentinel.version>
<shardingsphere-jdbc.version>5.1.1</shardingsphere-jdbc.version>
<shardingsphere-jdbc.version>5.2.1</shardingsphere-jdbc.version>
<redisson.version>3.19.1</redisson.version>
<spring-boot-admin.version>3.0.0-M1</spring-boot-admin.version>
<springdoc-openapi.version>2.0.0</springdoc-openapi.version>
@ -149,6 +149,11 @@
<artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
<version>${shardingsphere-jdbc.version}</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<!-- Spring Boot 管理和监控 -->
<dependency>

View File

@ -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 {
}

View File

@ -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"
}
]
}

View File

@ -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: