新增:数据源预热,三方模块配置区分环境

This commit is contained in:
yangyang01000846
2026-01-24 11:48:48 +08:00
parent 70fc5ae4cb
commit 0483596475
9 changed files with 227 additions and 52 deletions

View File

@@ -1,47 +0,0 @@
//package com.sdm.common.config;//package com.sdm.project.config.mybatis;
//
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Qualifier;
//import org.springframework.boot.ApplicationRunner;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//import javax.sql.DataSource;
//import java.sql.Connection;
//
//@Slf4j
//@Configuration
//public class DataSourcePreWarmer {
//
// @Bean
// public ApplicationRunner secondDataSourcePreWarmer(
// @Qualifier("secondDataSource") DataSource secondDataSource) {
// return args -> {
// try (Connection conn = secondDataSource.getConnection()) {
// log.info("✅ secondDataSource 预热成功,连接已建立: {}", conn);
// } catch (Exception e) {
// log.error("❌ secondDataSource 预热失败", e);
// throw new RuntimeException(e);
// }
// };
// }
//
// @Bean
// public ApplicationRunner mainDataSourcePreWarmer(
// @Qualifier("masterDataSource") DataSource master,
// @Qualifier("slaveDataSource") DataSource slave) {
// return args -> {
// try {
// try (Connection c1 = master.getConnection()) {
// log.info("✅ masterDataSource 预热成功: {}", c1);
// }
// try (Connection c2 = slave.getConnection()) {
// log.info("✅ slaveDataSource 预热成功: {}", c2);
// }
// } catch (Exception e) {
// log.error("❌ 主从数据源预热失败", e);
// throw new RuntimeException(e);
// }
// };
// }
//}

View File

@@ -208,13 +208,13 @@ public class AESUtil {
try {
// 优先读取JVM参数然后环境变量参数没有就报错
// String spdmEnkey = "H7qGt/DO3VdaAVKzY3PNvQ==";
// String spdmEnkey = "XzKRqYnUypdE8VJ41yo/i0rMpZ0IlztSZ1PqWhr0q/c=";
String spdmEnkey = StringUtils.isBlank(System.getProperty("spdm.enkey"))?
System.getenv("spdm.enkey"):System.getProperty("spdm.enkey");
if(StringUtils.isBlank(spdmEnkey)){
throw new RuntimeException("spdm加密配置密钥读取失败");
}
System.out.println("密钥是:"+spdmEnkey);
String ret = encodeNew("EP_DM@123.COM",spdmEnkey);
String ret = encodeNew("mysql",spdmEnkey);
System.out.println("encode:" + ret);
String raw = decodeNew(ret,spdmEnkey);
System.out.println("decode:" + raw);