From 470a2dbe6ed119373e4a6277fefeb2b38d85a328 Mon Sep 17 00:00:00 2001 From: zc Date: Thu, 7 May 2026 15:58:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E4=BB=8E=E5=BA=93=E5=8F=8C=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mybatis/DynamicRoutingDataSource.java | 18 +++ .../constant/DataSourceContextHolder.java | 40 +++++++ .../wms/admin/common/context/UserContext.java | 7 +- .../admin/common/enums/DataSourceEnum.java | 30 +++++ .../wms/admin/auth/AbstractLoginHandler.java | 11 +- .../mapper/FullWorkOrderMapper.java | 4 + .../wms/admin/system/model/entity/UserDO.java | 7 +- .../admin/system/model/req/user/UserReq.java | 6 + .../model/resp/user/UserDetailResp.java | 6 + .../system/model/resp/user/UserResp.java | 6 + .../resources/mapper/FullWorkOrderMapper.xml | 11 ++ .../src/main/resources/mapper/UserMapper.xml | 3 +- .../top/wms/admin/WmsAdminApplication.java | 5 +- .../admin/config/DynamicDataSourceConfig.java | 110 ++++++++++++++++++ .../config/DynamicDataSourceInterceptor.java | 59 ++++++++++ .../top/wms/admin/config/WebMvcConfig.java | 27 +++++ .../main/resources/config/application-dev.yml | 57 ++++----- 17 files changed, 374 insertions(+), 33 deletions(-) create mode 100644 wms-common/src/main/java/top/wms/admin/common/config/mybatis/DynamicRoutingDataSource.java create mode 100644 wms-common/src/main/java/top/wms/admin/common/constant/DataSourceContextHolder.java create mode 100644 wms-common/src/main/java/top/wms/admin/common/enums/DataSourceEnum.java create mode 100644 wms-webapi/src/main/java/top/wms/admin/config/DynamicDataSourceConfig.java create mode 100644 wms-webapi/src/main/java/top/wms/admin/config/DynamicDataSourceInterceptor.java create mode 100644 wms-webapi/src/main/java/top/wms/admin/config/WebMvcConfig.java diff --git a/wms-common/src/main/java/top/wms/admin/common/config/mybatis/DynamicRoutingDataSource.java b/wms-common/src/main/java/top/wms/admin/common/config/mybatis/DynamicRoutingDataSource.java new file mode 100644 index 0000000..eaa836b --- /dev/null +++ b/wms-common/src/main/java/top/wms/admin/common/config/mybatis/DynamicRoutingDataSource.java @@ -0,0 +1,18 @@ +package top.wms.admin.common.config.mybatis; + +import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; +import top.wms.admin.common.constant.DataSourceContextHolder; + +/** + * 动态数据源路由 + * + * @author Admin + * @since 2024/12/22 + */ +public class DynamicRoutingDataSource extends AbstractRoutingDataSource { + + @Override + protected Object determineCurrentLookupKey() { + return DataSourceContextHolder.getDataSource(); + } +} diff --git a/wms-common/src/main/java/top/wms/admin/common/constant/DataSourceContextHolder.java b/wms-common/src/main/java/top/wms/admin/common/constant/DataSourceContextHolder.java new file mode 100644 index 0000000..7b7cb47 --- /dev/null +++ b/wms-common/src/main/java/top/wms/admin/common/constant/DataSourceContextHolder.java @@ -0,0 +1,40 @@ +package top.wms.admin.common.constant; + +/** + * 数据源上下文 Holder + * + * @author Admin + * @since 2024/12/22 + */ +public class DataSourceContextHolder { + + private static final ThreadLocal CONTEXT_HOLDER = new ThreadLocal<>(); + + private DataSourceContextHolder() { + } + + /** + * 设置数据源 + * + * @param dataSource 数据源标识 + */ + public static void setDataSource(String dataSource) { + CONTEXT_HOLDER.set(dataSource); + } + + /** + * 获取数据源 + * + * @return 数据源标识 + */ + public static String getDataSource() { + return CONTEXT_HOLDER.get(); + } + + /** + * 清除数据源 + */ + public static void clearDataSource() { + CONTEXT_HOLDER.remove(); + } +} diff --git a/wms-common/src/main/java/top/wms/admin/common/context/UserContext.java b/wms-common/src/main/java/top/wms/admin/common/context/UserContext.java index 5bcd49c..1e6077e 100644 --- a/wms-common/src/main/java/top/wms/admin/common/context/UserContext.java +++ b/wms-common/src/main/java/top/wms/admin/common/context/UserContext.java @@ -74,6 +74,11 @@ public class UserContext implements Serializable { */ private String clientId; + /** + * 数据源标识 + */ + private String dataSource; + public UserContext(Set permissions, Set roles, Integer passwordExpirationDays) { this.permissions = permissions; this.setRoles(roles); @@ -113,4 +118,4 @@ public class UserContext implements Serializable { } return this.pwdResetTime.plusDays(this.passwordExpirationDays).isBefore(LocalDateTime.now()); } -} +} \ No newline at end of file diff --git a/wms-common/src/main/java/top/wms/admin/common/enums/DataSourceEnum.java b/wms-common/src/main/java/top/wms/admin/common/enums/DataSourceEnum.java new file mode 100644 index 0000000..6349dc2 --- /dev/null +++ b/wms-common/src/main/java/top/wms/admin/common/enums/DataSourceEnum.java @@ -0,0 +1,30 @@ +package top.wms.admin.common.enums; + +/** + * 数据源枚举 + * + * @author Admin + * @since 2024/12/22 + */ +public enum DataSourceEnum { + + /** + * 主数据源 + */ + WMS("wms"), + + /** + * 从数据源 + */ + WMS2("wms2"); + + private final String value; + + DataSourceEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } +} diff --git a/wms-module-system/src/main/java/top/wms/admin/auth/AbstractLoginHandler.java b/wms-module-system/src/main/java/top/wms/admin/auth/AbstractLoginHandler.java index c708a85..b24879a 100644 --- a/wms-module-system/src/main/java/top/wms/admin/auth/AbstractLoginHandler.java +++ b/wms-module-system/src/main/java/top/wms/admin/auth/AbstractLoginHandler.java @@ -8,6 +8,7 @@ import jakarta.servlet.http.HttpServletRequest; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.stereotype.Component; import top.wms.admin.auth.model.req.LoginReq; +import top.wms.admin.common.constant.DataSourceContextHolder; import top.wms.admin.common.context.RoleContext; import top.wms.admin.common.context.UserContext; import top.wms.admin.common.context.UserContextHolder; @@ -91,6 +92,14 @@ public abstract class AbstractLoginHandler implements LoginH userContext.setClientType(client.getClientType()); model.setExtra(CLIENT_ID, client.getClientId()); userContext.setClientId(client.getClientId()); + // 设置数据源(如果用户未配置,则使用默认主库) + String dataSource = user.getDataSource(); + if (dataSource == null || dataSource.isEmpty()) { + dataSource = "wms"; // 默认主库 + } + userContext.setDataSource(dataSource); + DataSourceContextHolder.setDataSource(dataSource); + // 登录并缓存用户信息 StpUtil.login(userContext.getId(), model.setExtraData(BeanUtil.beanToMap(new UserExtraContext(SpringWebUtils .getRequest())))); @@ -108,4 +117,4 @@ public abstract class AbstractLoginHandler implements LoginH // DeptDO dept = deptService.getById(user.getDeptId()); // CheckUtils.throwIfEqual(DisEnableStatusEnum.DISABLE, dept.getStatus(), "此账号所属部门已被禁用,如有疑问,请联系管理员"); } -} +} \ No newline at end of file diff --git a/wms-module-system/src/main/java/top/wms/admin/fullWorkOrder/mapper/FullWorkOrderMapper.java b/wms-module-system/src/main/java/top/wms/admin/fullWorkOrder/mapper/FullWorkOrderMapper.java index 680bcce..0ac2a26 100644 --- a/wms-module-system/src/main/java/top/wms/admin/fullWorkOrder/mapper/FullWorkOrderMapper.java +++ b/wms-module-system/src/main/java/top/wms/admin/fullWorkOrder/mapper/FullWorkOrderMapper.java @@ -10,6 +10,8 @@ import top.continew.starter.data.mp.base.BaseMapper; import top.wms.admin.fullWorkOrder.model.entity.FullWorkOrderDO; import top.wms.admin.fullWorkOrder.model.resp.FullWorkOrderResp; +import java.util.List; + /** * 整箱领取记录 Mapper * @@ -21,4 +23,6 @@ public interface FullWorkOrderMapper extends BaseMapper { IPage selectFullWorkOrderPage(@Param("page") Page objectPage, @Param(Constants.WRAPPER) QueryWrapper queryWrapper); + + List selectFullWorkOrderExport(@Param(Constants.WRAPPER) QueryWrapper queryWrapper); } \ No newline at end of file diff --git a/wms-module-system/src/main/java/top/wms/admin/system/model/entity/UserDO.java b/wms-module-system/src/main/java/top/wms/admin/system/model/entity/UserDO.java index 3bcea43..fb674b0 100644 --- a/wms-module-system/src/main/java/top/wms/admin/system/model/entity/UserDO.java +++ b/wms-module-system/src/main/java/top/wms/admin/system/model/entity/UserDO.java @@ -92,4 +92,9 @@ public class UserDO extends BaseDO { */ @TableField(exist = false) private Long equipmentId; -} + + /** + * 数据源标识(wms/wms2) + */ + private String dataSource; +} \ No newline at end of file diff --git a/wms-module-system/src/main/java/top/wms/admin/system/model/req/user/UserReq.java b/wms-module-system/src/main/java/top/wms/admin/system/model/req/user/UserReq.java index 1934d20..9a7273d 100644 --- a/wms-module-system/src/main/java/top/wms/admin/system/model/req/user/UserReq.java +++ b/wms-module-system/src/main/java/top/wms/admin/system/model/req/user/UserReq.java @@ -93,6 +93,12 @@ public class UserReq implements Serializable { @Schema(description = "状态", example = "1") private DisEnableStatusEnum status; + /** + * 状态 + */ + @Schema(description = "数据源") + private String dataSource; + /** * 设备ID */ diff --git a/wms-module-system/src/main/java/top/wms/admin/system/model/resp/user/UserDetailResp.java b/wms-module-system/src/main/java/top/wms/admin/system/model/resp/user/UserDetailResp.java index 06ef87b..699fb3a 100644 --- a/wms-module-system/src/main/java/top/wms/admin/system/model/resp/user/UserDetailResp.java +++ b/wms-module-system/src/main/java/top/wms/admin/system/model/resp/user/UserDetailResp.java @@ -116,6 +116,12 @@ public class UserDetailResp extends BaseDetailResp { @Schema(description = "设备ID") private Long equipmentId; + /** + * 数据源 + */ + @Schema(description = "数据源") + private String dataSource; + @Override public Boolean getDisabled() { return this.getIsSystem() || Objects.equals(this.getId(), UserContextHolder.getUserId()); diff --git a/wms-module-system/src/main/java/top/wms/admin/system/model/resp/user/UserResp.java b/wms-module-system/src/main/java/top/wms/admin/system/model/resp/user/UserResp.java index 71a1287..9b7f904 100644 --- a/wms-module-system/src/main/java/top/wms/admin/system/model/resp/user/UserResp.java +++ b/wms-module-system/src/main/java/top/wms/admin/system/model/resp/user/UserResp.java @@ -81,6 +81,12 @@ public class UserResp extends BaseDetailResp { @Schema(description = "描述", example = "张三描述信息") private String description; + /** + * 状态 + */ + @Schema(description = "数据源") + private String dataSource; + /** * 角色名称列表 */ diff --git a/wms-module-system/src/main/resources/mapper/FullWorkOrderMapper.xml b/wms-module-system/src/main/resources/mapper/FullWorkOrderMapper.xml index 40e2517..909b7b8 100644 --- a/wms-module-system/src/main/resources/mapper/FullWorkOrderMapper.xml +++ b/wms-module-system/src/main/resources/mapper/FullWorkOrderMapper.xml @@ -12,4 +12,15 @@ left join sys_user u on f.create_user = u.id ${ew.customSqlSegment} + \ No newline at end of file diff --git a/wms-module-system/src/main/resources/mapper/UserMapper.xml b/wms-module-system/src/main/resources/mapper/UserMapper.xml index 54b90f0..5a862a0 100644 --- a/wms-module-system/src/main/resources/mapper/UserMapper.xml +++ b/wms-module-system/src/main/resources/mapper/UserMapper.xml @@ -22,7 +22,8 @@ t1.is_system, t1.pwd_reset_time, t1.dept_id, - t2.name AS deptName + t2.name AS deptName, + t1.data_source FROM sys_user AS t1 LEFT JOIN sys_dept AS t2 ON t2.id = t1.dept_id diff --git a/wms-webapi/src/main/java/top/wms/admin/WmsAdminApplication.java b/wms-webapi/src/main/java/top/wms/admin/WmsAdminApplication.java index be304a8..2d84080 100644 --- a/wms-webapi/src/main/java/top/wms/admin/WmsAdminApplication.java +++ b/wms-webapi/src/main/java/top/wms/admin/WmsAdminApplication.java @@ -8,6 +8,7 @@ import lombok.extern.slf4j.Slf4j; import org.dromara.x.file.storage.spring.EnableFileStorage; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @@ -28,7 +29,7 @@ import top.continew.starter.web.model.R; @EnableGlobalResponse @EnableCrudRestController @RestController -@SpringBootApplication +@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) @RequiredArgsConstructor @EnableScheduling public class WmsAdminApplication { @@ -46,4 +47,4 @@ public class WmsAdminApplication { return R.ok(projectProperties); } -} +} \ No newline at end of file diff --git a/wms-webapi/src/main/java/top/wms/admin/config/DynamicDataSourceConfig.java b/wms-webapi/src/main/java/top/wms/admin/config/DynamicDataSourceConfig.java new file mode 100644 index 0000000..2303cda --- /dev/null +++ b/wms-webapi/src/main/java/top/wms/admin/config/DynamicDataSourceConfig.java @@ -0,0 +1,110 @@ +package top.wms.admin.config; + +import com.zaxxer.hikari.HikariConfig; +import com.zaxxer.hikari.HikariDataSource; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.jdbc.datasource.DataSourceTransactionManager; +import org.springframework.transaction.PlatformTransactionManager; +import top.wms.admin.common.config.mybatis.DynamicRoutingDataSource; + +import javax.sql.DataSource; +import java.util.HashMap; +import java.util.Map; + +/** + * 动态数据源配置 + * + * @author Admin + * @since 2024/12/22 + */ +@Configuration +public class DynamicDataSourceConfig { + + @Value("${spring.datasource.wms.url}") + private String wmsUrl; + + @Value("${spring.datasource.wms.username}") + private String wmsUsername; + + @Value("${spring.datasource.wms.password}") + private String wmsPassword; + + @Value("${spring.datasource.wms2.url}") + private String wms2Url; + + @Value("${spring.datasource.wms2.username}") + private String wms2Username; + + @Value("${spring.datasource.wms2.password}") + private String wms2Password; + + /** + * 主数据源(wms) + */ + @Bean("wmsDataSource") + public DataSource wmsDataSource() { + HikariConfig config = new HikariConfig(); + config.setDriverClassName("com.p6spy.engine.spy.P6SpyDriver"); + config.setJdbcUrl(wmsUrl); + config.setUsername(wmsUsername); + config.setPassword(wmsPassword); + config.setMaximumPoolSize(20); + config.setConnectionTimeout(30000); + config.setIdleTimeout(600000); + config.setKeepaliveTime(30000); + config.setMaxLifetime(1800000); + return new HikariDataSource(config); + } + + /** + * 从数据源(wms2) + */ + @Bean("wms2DataSource") + public DataSource wms2DataSource() { + HikariConfig config = new HikariConfig(); + config.setDriverClassName("com.p6spy.engine.spy.P6SpyDriver"); + config.setJdbcUrl(wms2Url); + config.setUsername(wms2Username); + config.setPassword(wms2Password); + config.setMaximumPoolSize(20); + config.setConnectionTimeout(30000); + config.setIdleTimeout(600000); + config.setKeepaliveTime(30000); + config.setMaxLifetime(1800000); + return new HikariDataSource(config); + } + + /** + * 动态数据源 + */ + @Bean("dynamicDataSource") + @Primary + public DataSource dynamicDataSource(DataSource wmsDataSource, DataSource wms2DataSource) { + DynamicRoutingDataSource dynamicRoutingDataSource = new DynamicRoutingDataSource(); + + // 设置默认数据源 + dynamicRoutingDataSource.setDefaultTargetDataSource(wmsDataSource); + + // 设置数据源映射 + Map dataSourceMap = new HashMap<>(); + dataSourceMap.put("wms", wmsDataSource); + dataSourceMap.put("wms2", wms2DataSource); + dynamicRoutingDataSource.setTargetDataSources(dataSourceMap); + + // 必须调用此方法,否则首次获取数据源时会失败 + dynamicRoutingDataSource.afterPropertiesSet(); + + return dynamicRoutingDataSource; + } + + /** + * 事务管理器 + */ + @Bean + public PlatformTransactionManager transactionManager(DataSource dynamicDataSource) { + return new DataSourceTransactionManager(dynamicDataSource); + } +} \ No newline at end of file diff --git a/wms-webapi/src/main/java/top/wms/admin/config/DynamicDataSourceInterceptor.java b/wms-webapi/src/main/java/top/wms/admin/config/DynamicDataSourceInterceptor.java new file mode 100644 index 0000000..0c584d0 --- /dev/null +++ b/wms-webapi/src/main/java/top/wms/admin/config/DynamicDataSourceInterceptor.java @@ -0,0 +1,59 @@ +package top.wms.admin.config; + +import cn.dev33.satoken.stp.StpUtil; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import org.springframework.lang.Nullable; +import org.springframework.stereotype.Component; +import org.springframework.web.servlet.HandlerInterceptor; +import top.wms.admin.common.constant.DataSourceContextHolder; +import top.wms.admin.common.context.UserContext; +import top.wms.admin.common.context.UserContextHolder; + +/** + * 动态数据源拦截器 + * 在每次请求时根据当前登录用户切换数据源 + * + * @author Admin + * @since 2024/12/22 + */ +@Component +public class DynamicDataSourceInterceptor implements HandlerInterceptor { + + @Override + public boolean preHandle(HttpServletRequest request, + HttpServletResponse response, + Object handler) throws Exception { + String requestUri = request.getRequestURI(); + + // 认证相关接口始终使用主库(wms),确保用户验证和权限获取在主库进行 + if (requestUri.contains("/auth/login") || requestUri.contains("/auth/user/info") || requestUri + .contains("/auth/user/route") || requestUri.contains("/auth/logout")) { + DataSourceContextHolder.setDataSource("wms"); + return true; + } + + // 如果用户已登录,从用户上下文获取数据源并设置 + if (StpUtil.isLogin()) { + try { + UserContext userContext = UserContextHolder.getContext(); + if (userContext != null && userContext.getDataSource() != null) { + DataSourceContextHolder.setDataSource(userContext.getDataSource()); + } + } catch (Exception e) { + // 如果获取用户上下文失败,使用默认数据源 + DataSourceContextHolder.clearDataSource(); + } + } + return true; + } + + @Override + public void afterCompletion(HttpServletRequest request, + HttpServletResponse response, + Object handler, + @Nullable Exception ex) throws Exception { + // 请求结束后清除数据源上下文 + DataSourceContextHolder.clearDataSource(); + } +} \ No newline at end of file diff --git a/wms-webapi/src/main/java/top/wms/admin/config/WebMvcConfig.java b/wms-webapi/src/main/java/top/wms/admin/config/WebMvcConfig.java new file mode 100644 index 0000000..44a369e --- /dev/null +++ b/wms-webapi/src/main/java/top/wms/admin/config/WebMvcConfig.java @@ -0,0 +1,27 @@ +package top.wms.admin.config; + +import lombok.RequiredArgsConstructor; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +/** + * WebMvc 配置 + * + * @author Admin + * @since 2024/12/22 + */ +@Configuration +@RequiredArgsConstructor +public class WebMvcConfig implements WebMvcConfigurer { + + private final DynamicDataSourceInterceptor dynamicDataSourceInterceptor; + + @Override + public void addInterceptors(InterceptorRegistry registry) { + // 注册动态数据源拦截器,优先级高于其他拦截器 + registry.addInterceptor(dynamicDataSourceInterceptor) + .addPathPatterns("/**") + .excludePathPatterns("/error", "/doc.html", "/webjars/**", "/swagger-ui/**", "/swagger-resources/**", "/*/api-docs/**", "/favicon.ico"); + } +} \ No newline at end of file diff --git a/wms-webapi/src/main/resources/config/application-dev.yml b/wms-webapi/src/main/resources/config/application-dev.yml index 8a8acd4..adb1006 100644 --- a/wms-webapi/src/main/resources/config/application-dev.yml +++ b/wms-webapi/src/main/resources/config/application-dev.yml @@ -16,33 +16,36 @@ spring: --- ### 数据源配置 spring.datasource: - type: com.zaxxer.hikari.HikariDataSource - # 请务必提前创建好名为 wms_admin 的数据库,如果使用其他数据库名请注意同步修改 DB_NAME 配置 - url: jdbc:p6spy:mysql://127.0.0.1:3306/wms?serverTimezone=Asia/Shanghai&useSSL=false&useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&autoReconnect=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true - username: root -# password: root - password: test123$ - # PostgreSQL 配置 -# url: jdbc:p6spy:mysql://192.168.2.30:${DB_PORT:3306}/continew?serverTimezone=Asia/Shanghai&useSSL=true&useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&autoReconnect=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true -# username: ${DB_USER:root} -# password: ${DB_PWD:SQLsql123} -# url: jdbc:p6spy:mysql://81.68.71.142:${DB_PORT:3306}/continew?serverTimezone=Asia/Shanghai&useSSL=true&useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&autoReconnect=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true -# username: ${DB_USER:root} -# password: ${DB_PWD:MYsql12@} - driver-class-name: com.p6spy.engine.spy.P6SpyDriver - # Hikari 连接池配置 - hikari: - # 最大连接数量(默认 10,根据实际环境调整) - # 注意:当连接达到上限,并且没有空闲连接可用时,获取连接将在超时前阻塞最多 connectionTimeout 毫秒 - maximum-pool-size: 20 - # 获取连接超时时间(默认 30000 毫秒,30 秒) - connection-timeout: 30000 - # 空闲连接最大存活时间(默认 600000 毫秒,10 分钟) - idle-timeout: 600000 - # 保持连接活动的频率,以防止它被数据库或网络基础设施超时。该值必须小于 maxLifetime(默认 0,禁用) - keepaliveTime: 30000 - # 连接最大生存时间(默认 1800000 毫秒,30 分钟) - max-lifetime: 1800000 + # 主数据源(wms) + wms: + type: com.zaxxer.hikari.HikariDataSource + driver-class-name: com.p6spy.engine.spy.P6SpyDriver + url: jdbc:p6spy:mysql://127.0.0.1:3306/wms?serverTimezone=Asia/Shanghai&useSSL=false&useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&autoReconnect=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true + username: root +# password: root + password: test123$ + # Hikari 连接池配置 + hikari: + maximum-pool-size: 20 + connection-timeout: 30000 + idle-timeout: 600000 + keepaliveTime: 30000 + max-lifetime: 1800000 + # 从数据源(wms2) + wms2: + type: com.zaxxer.hikari.HikariDataSource + driver-class-name: com.p6spy.engine.spy.P6SpyDriver + url: jdbc:p6spy:mysql://127.0.0.1:3306/wms2?serverTimezone=Asia/Shanghai&useSSL=false&useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&autoReconnect=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true + username: root +# password: root + password: test123$ + # Hikari 连接池配置 + hikari: + maximum-pool-size: 20 + connection-timeout: 30000 + idle-timeout: 600000 + keepaliveTime: 30000 + max-lifetime: 1800000 ## Liquibase 配置 spring.liquibase: # 是否启用