feat:数据库配置简化

V0.5.x
xiwa 2024-03-21 00:01:29 +08:00
parent cfc30500cc
commit 1c9b9ce046
4 changed files with 23 additions and 60 deletions

View File

@ -70,11 +70,6 @@
<!-- <version>42.2.9</version>--> <!-- <version>42.2.9</version>-->
<!-- </dependency>--> <!-- </dependency>-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
</dependency>
<dependency> <dependency>
<groupId>cn.hutool</groupId> <groupId>cn.hutool</groupId>
<artifactId>hutool-core</artifactId> <artifactId>hutool-core</artifactId>

View File

@ -16,7 +16,6 @@ import cc.iotkit.system.dto.vo.SysTenantVo;
import cc.iotkit.system.service.ISysTenantService; import cc.iotkit.system.service.ISysTenantService;
import cn.dev33.satoken.annotation.SaCheckPermission; import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaCheckRole; import cn.dev33.satoken.annotation.SaCheckRole;
import com.baomidou.lock.annotation.Lock4j;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotBlank;
@ -86,7 +85,6 @@ public class SysTenantController extends BaseController {
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY) @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
@SaCheckPermission("system:tenant:add") @SaCheckPermission("system:tenant:add")
@Log(title = "租户", businessType = BusinessType.INSERT) @Log(title = "租户", businessType = BusinessType.INSERT)
@Lock4j
@PostMapping("/add") @PostMapping("/add")
public void add(@Validated(AddGroup.class) @RequestBody Request<SysTenantBo> bo) { public void add(@Validated(AddGroup.class) @RequestBody Request<SysTenantBo> bo) {
SysTenantBo data = bo.getData(); SysTenantBo data = bo.getData();

View File

@ -20,28 +20,17 @@ spring:
format_sql: true format_sql: true
datasource: datasource:
type: com.zaxxer.hikari.HikariDataSource type: com.zaxxer.hikari.HikariDataSource
# 动态数据源文档 https://www.kancloud.cn/tracy5546/dynamic-datasource/content driverClassName: org.h2.Driver
dynamic: url: jdbc:h2:./data/iotkit;MODE=MySQL
hikari: username: sa
connection-timeout: 5000 password: 123456
idle-timeout: 30000 # 经过idle-timeout时间如果连接还处于空闲状态, 该连接会被回收 hikari:
min-idle: 5 # 池中维护的最小空闲连接数, 默认为 10 个 connection-timeout: 5000
max-pool-size: 16 # 池中最大连接数, 包括闲置和使用中的连接, 默认为 10 个 idle-timeout: 30000 # 经过idle-timeout时间如果连接还处于空闲状态, 该连接会被回收
max-lifetime: 60000 # 如果一个连接超过了时长,且没有被使用, 连接会被回收 min-idle: 5 # 池中维护的最小空闲连接数, 默认为 10 个
is-auto-commit: true max-pool-size: 16 # 池中最大连接数, 包括闲置和使用中的连接, 默认为 10 个
primary: master #设置默认的数据源或者数据源组,默认值即为master max-lifetime: 60000 # 如果一个连接超过了时长,且没有被使用, 连接会被回收
strict: true #严格匹配数据源,默认false. true未匹配到指定数据源时抛异常,false使用默认数据源 is-auto-commit: true
datasource:
# 主库数据源
master:
type: ${spring.datasource.type}
driverClassName: org.h2.Driver
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
url: jdbc:h2:./data/iotkit;MODE=MySQL
username: sa
password: 123456
# 内置h2 web console设置 # 内置h2 web console设置
platform: h2 platform: h2
h2: h2:
@ -64,25 +53,18 @@ spring:
# format_sql: true # format_sql: true
# datasource: # datasource:
# type: com.zaxxer.hikari.HikariDataSource # type: com.zaxxer.hikari.HikariDataSource
# dynamic: # driverClassName: com.mysql.cj.jdbc.Driver
# hikari: # # jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
# connection-timeout: 5000 # url: jdbc:mysql://127.0.0.1:3306/iotkit?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC&useSSL=false
# idle-timeout: 30000 # 经过idle-timeout时间如果连接还处于空闲状态, 该连接会被回收 # username: root
# min-idle: 5 # 池中维护的最小空闲连接数, 默认为 10 个 # password: 123456
# max-pool-size: 16 # 池中最大连接数, 包括闲置和使用中的连接, 默认为 10 个 # hikari:
# max-lifetime: 60000 # 如果一个连接超过了时长,且没有被使用, 连接会被回收 # connection-timeout: 5000
# is-auto-commit: true # idle-timeout: 30000 # 经过idle-timeout时间如果连接还处于空闲状态, 该连接会被回收
# primary: master #设置默认的数据源或者数据源组,默认值即为master # min-idle: 5 # 池中维护的最小空闲连接数, 默认为 10 个
# strict: true #严格匹配数据源,默认false. true未匹配到指定数据源时抛异常,false使用默认数据源 # max-pool-size: 16 # 池中最大连接数, 包括闲置和使用中的连接, 默认为 10 个
# datasource: # max-lifetime: 60000 # 如果一个连接超过了时长,且没有被使用, 连接会被回收
# # 主库数据源 # is-auto-commit: true
# master:
# type: ${spring.datasource.type}
# driverClassName: com.mysql.cj.jdbc.Driver
# # jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
# url: jdbc:mysql://127.0.0.1:3306/iotkit?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC&useSSL=false
# username: root
# password: 123456
# ============mysql配置结束============>> # ============mysql配置结束============>>
#<<================es时序数据配置开始=============== #<<================es时序数据配置开始===============

12
pom.xml
View File

@ -85,12 +85,6 @@
<version>${lombok.version}</version> <version>${lombok.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.directory.studio</groupId>
<artifactId>org.apache.commons.codec</artifactId>
<version>1.8</version>
</dependency>
<dependency> <dependency>
<groupId>jakarta.servlet</groupId> <groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId> <artifactId>jakarta.servlet-api</artifactId>
@ -193,12 +187,6 @@
<version>1.0.0</version> <version>1.0.0</version>
</dependency> </dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
<version>3.5.1</version>
</dependency>
<dependency> <dependency>
<groupId>com.github.xiaoymin</groupId> <groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId> <artifactId>knife4j-spring-boot-starter</artifactId>