初始化项目
This commit is contained in:
109
web-api/src/main/java/com/jeesite/modules/utils/AesUtil.java
Normal file
109
web-api/src/main/java/com/jeesite/modules/utils/AesUtil.java
Normal file
@@ -0,0 +1,109 @@
|
||||
package com.jeesite.modules.utils;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
/**
|
||||
* AES加密解密工具类(CBC/PKCS5Padding)
|
||||
* 优化说明:修复密钥BUG+解决换行问题+性能优化+安全加固+零依赖
|
||||
*/
|
||||
public class AesUtil {
|
||||
|
||||
|
||||
private static final LoggerUtils logger = LoggerUtils.getInstance();
|
||||
private static final String AES_KEY_HEX = "AD42F6697B035B7580E4FEF93BE20BAD"; // 你的32位16进制密钥
|
||||
private static final String CHARSET = StandardCharsets.UTF_8.name();
|
||||
private static final int IV_LENGTH = 16; // AES CBC IV固定16字节
|
||||
private static final String TRANSFORMATION = "AES/CBC/PKCS5Padding";
|
||||
private static final String ALGORITHM = "AES";
|
||||
|
||||
private static final ThreadLocal<Cipher> ENCRYPT_CIPHER = ThreadLocal.withInitial(() -> {
|
||||
try {
|
||||
return Cipher.getInstance(TRANSFORMATION);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
private static final ThreadLocal<Cipher> DECRYPT_CIPHER = ThreadLocal.withInitial(() -> {
|
||||
try {
|
||||
return Cipher.getInstance(TRANSFORMATION);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 加密
|
||||
*/
|
||||
public static String encrypt(String content) {
|
||||
return encrypt(content, hex2Bytes(AES_KEY_HEX));
|
||||
}
|
||||
|
||||
/**
|
||||
* 解密
|
||||
*/
|
||||
public static String decrypt(String content) {
|
||||
return decrypt(content, hex2Bytes(AES_KEY_HEX));
|
||||
}
|
||||
|
||||
public static String encrypt(String content, byte[] key) {
|
||||
if (content == null || content.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
try {
|
||||
SecretKeySpec secretKey = new SecretKeySpec(key, ALGORITHM);
|
||||
IvParameterSpec iv = new IvParameterSpec(Arrays.copyOf(key, IV_LENGTH));
|
||||
Cipher cipher = ENCRYPT_CIPHER.get();
|
||||
cipher.init(Cipher.ENCRYPT_MODE, secretKey, iv);
|
||||
byte[] encryptBytes = cipher.doFinal(content.getBytes(CHARSET));
|
||||
return Base64.getEncoder().encodeToString(encryptBytes);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static String decrypt(String content, byte[] key) {
|
||||
if (content == null || content.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
try {
|
||||
SecretKeySpec secretKey = new SecretKeySpec(key, ALGORITHM);
|
||||
IvParameterSpec iv = new IvParameterSpec(Arrays.copyOf(key, IV_LENGTH));
|
||||
Cipher cipher = DECRYPT_CIPHER.get();
|
||||
cipher.init(Cipher.DECRYPT_MODE, secretKey, iv);
|
||||
byte[] decryptBytes = cipher.doFinal(Base64.getDecoder().decode(content));
|
||||
String result = new String(decryptBytes, CHARSET);
|
||||
return result.trim();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 32位16进制字符串转16字节数组(解决你的密钥长度BUG的核心方法)
|
||||
*/
|
||||
private static byte[] hex2Bytes(String hexStr) {
|
||||
if (hexStr == null || hexStr.length() % 2 != 0) {
|
||||
throw new IllegalArgumentException("密钥必须是偶数长度的16进制字符串");
|
||||
}
|
||||
byte[] bytes = new byte[hexStr.length() / 2];
|
||||
for (int i = 0; i < bytes.length; i++) {
|
||||
bytes[i] = (byte) Integer.parseInt(hexStr.substring(i * 2, i * 2 + 2), 16);
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成随机16字节IV向量(方案2:安全随机IV,新业务推荐使用)
|
||||
*/
|
||||
private static byte[] generateRandomIV() {
|
||||
byte[] iv = new byte[IV_LENGTH];
|
||||
ThreadLocalRandom.current().nextBytes(iv);
|
||||
return iv;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.jeesite.modules.utils;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
public class DateUtils {
|
||||
private static final DateTimeFormatter MONTH_FORMATTER = DateTimeFormatter.ofPattern("MM");
|
||||
private static final DateTimeFormatter YEAR_FORMATTER = DateTimeFormatter.ofPattern("yyyy");
|
||||
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||
private static final DateTimeFormatter YEAR_MONTH_CN_FORMATTER = DateTimeFormatter.ofPattern("yyyy年MM月");
|
||||
|
||||
private static final DateTimeFormatter SHORT_YEAR_MONTH_CN_FORMATTER = DateTimeFormatter.ofPattern("yy年MM月");
|
||||
|
||||
|
||||
|
||||
public static String dsValue() {
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
return currentDate.format(DATE_FORMATTER);
|
||||
}
|
||||
|
||||
public static String dsValueDaysAgo(long days) {
|
||||
LocalDate targetDate = LocalDate.now().minusDays(days);
|
||||
return targetDate.format(DATE_FORMATTER);
|
||||
}
|
||||
|
||||
public static String getCurrentYear() {
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
return currentDate.format(YEAR_FORMATTER);
|
||||
}
|
||||
|
||||
public static String getCurrentMonth() {
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
return currentDate.format(MONTH_FORMATTER);
|
||||
}
|
||||
|
||||
public static String getCurrentYearMonthCN() {
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
return currentDate.format(YEAR_MONTH_CN_FORMATTER);
|
||||
}
|
||||
|
||||
public static String getCurrentShortYearMonthCN() {
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
return currentDate.format(SHORT_YEAR_MONTH_CN_FORMATTER);
|
||||
}
|
||||
|
||||
public static String getYear(LocalDate date) {
|
||||
return date.format(YEAR_FORMATTER);
|
||||
}
|
||||
|
||||
public static String getMonth(LocalDate date) {
|
||||
return date.format(MONTH_FORMATTER);
|
||||
}
|
||||
}
|
||||
48
web-api/src/main/java/com/jeesite/modules/utils/KeyUtil.java
Normal file
48
web-api/src/main/java/com/jeesite/modules/utils/KeyUtil.java
Normal file
@@ -0,0 +1,48 @@
|
||||
package com.jeesite.modules.utils;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class KeyUtil {
|
||||
|
||||
public static String ObjKey(int length, int type) {
|
||||
Random random = new Random();
|
||||
StringBuffer key = new StringBuffer();
|
||||
if (type == 1) {
|
||||
String str = "0123456789";
|
||||
for (int i = 0; i < length; ++i) {
|
||||
//从62个的数字或字母中选择
|
||||
int number = random.nextInt(10);
|
||||
//将产生的数字通过length次承载到key中
|
||||
key.append(str.charAt(number));
|
||||
}
|
||||
return key.toString();
|
||||
} else if (type == 2) {
|
||||
String str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
for (int i = 0; i < length; ++i) {
|
||||
//从62个的数字或字母中选择
|
||||
int number = random.nextInt(36);
|
||||
//将产生的数字通过length次承载到key中
|
||||
key.append(str.charAt(number));
|
||||
}
|
||||
return key.toString();
|
||||
} else if (type == 3) {
|
||||
String str = "abcdefghijklmnopqrstuvwxyz0123456789";
|
||||
for (int i = 0; i < length; ++i) {
|
||||
//从62个的数字或字母中选择
|
||||
int number = random.nextInt(36);
|
||||
//将产生的数字通过length次承载到key中
|
||||
key.append(str.charAt(number));
|
||||
}
|
||||
return key.toString();
|
||||
} else {
|
||||
String str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
for (int i = 0; i < length; ++i) {
|
||||
//从62个的数字或字母中选择
|
||||
int number = random.nextInt(62);
|
||||
//将产生的数字通过length次承载到key中
|
||||
key.append(str.charAt(number));
|
||||
}
|
||||
return key.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
187
web-api/src/main/java/com/jeesite/modules/utils/LoggerUtils.java
Normal file
187
web-api/src/main/java/com/jeesite/modules/utils/LoggerUtils.java
Normal file
@@ -0,0 +1,187 @@
|
||||
package com.jeesite.modules.utils;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
|
||||
public class LoggerUtils {
|
||||
|
||||
// 日志级别
|
||||
public enum Level {
|
||||
DEBUG, INFO, WARN, ERROR
|
||||
}
|
||||
|
||||
// 单例实例
|
||||
private static volatile LoggerUtils instance;
|
||||
|
||||
private String baseLogPath;
|
||||
|
||||
|
||||
private final SimpleDateFormat logDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
|
||||
|
||||
// 线程安全锁
|
||||
private final ReentrantLock lock = new ReentrantLock();
|
||||
|
||||
// 禁止外部实例化
|
||||
private LoggerUtils(String baseLogPath) {
|
||||
this.baseLogPath = baseLogPath;
|
||||
initLogDir(); // 初始化日志目录
|
||||
}
|
||||
|
||||
public static LoggerUtils getInstance() {
|
||||
return getInstance("/ogsapp/logs");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单例实例(自定义日志路径)
|
||||
*
|
||||
* @param baseLogPath 日志根目录(支持相对路径或绝对路径)
|
||||
*/
|
||||
public static LoggerUtils getInstance(String baseLogPath) {
|
||||
if (instance == null) {
|
||||
synchronized (LoggerUtils.class) {
|
||||
if (instance == null) {
|
||||
instance = new LoggerUtils(baseLogPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化日志目录(若不存在则创建多级目录)
|
||||
*/
|
||||
private void initLogDir() {
|
||||
try {
|
||||
Files.createDirectories(Paths.get(baseLogPath));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("初始化日志目录失败:" + baseLogPath, e);
|
||||
}
|
||||
}
|
||||
|
||||
private String getCurrentLogFilePath(Level level) {
|
||||
String fileName = level + "_APP" + ".log";
|
||||
return baseLogPath + File.separator + fileName;
|
||||
}
|
||||
|
||||
// ------------------------------ 日志方法(支持多类型可变参数) ------------------------------
|
||||
|
||||
/**
|
||||
* 记录DEBUG级别日志(支持1到多个任意类型参数)
|
||||
*/
|
||||
public void debug(Object... messages) {
|
||||
log(Level.DEBUG, joinMessages(messages), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录INFO级别日志(支持1到多个任意类型参数)
|
||||
*/
|
||||
public void info(Object... messages) {
|
||||
log(Level.INFO, joinMessages(messages), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录WARN级别日志(支持1到多个任意类型参数)
|
||||
*/
|
||||
public void warn(Object... messages) {
|
||||
log(Level.WARN, joinMessages(messages), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录WARN级别日志(支持1到多个任意类型参数+异常)
|
||||
*/
|
||||
public void warn(Object[] messages, Throwable throwable) {
|
||||
log(Level.WARN, joinMessages(messages), throwable);
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录ERROR级别日志(支持1到多个任意类型参数)
|
||||
*/
|
||||
public void error(Object... messages) {
|
||||
log(Level.ERROR, joinMessages(messages), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录ERROR级别日志(支持1到多个任意类型参数+异常)
|
||||
*/
|
||||
public void error(Object[] messages, Throwable throwable) {
|
||||
log(Level.ERROR, joinMessages(messages), throwable);
|
||||
}
|
||||
|
||||
// ------------------------------ 核心方法 ------------------------------
|
||||
|
||||
/**
|
||||
* 核心日志写入逻辑
|
||||
*/
|
||||
private void log(Level level, String message, Throwable throwable) {
|
||||
// 构建日志内容
|
||||
StringBuilder logContent = new StringBuilder();
|
||||
logContent.append("[").append(logDateFormat.format(new Date())).append("] "); // 时间戳
|
||||
logContent.append("[").append(level.name()).append("] "); // 日志级别
|
||||
logContent.append("[Thread-").append(Thread.currentThread().getId()).append("] "); // 线程ID
|
||||
logContent.append(message); // 拼接后的消息
|
||||
|
||||
// 追加异常堆栈信息(如果有)
|
||||
if (throwable != null) {
|
||||
logContent.append("\n").append(getStackTrace(throwable));
|
||||
}
|
||||
logContent.append("\n"); // 每条日志换行
|
||||
|
||||
// 加锁写入文件(保证线程安全)
|
||||
lock.lock();
|
||||
try (BufferedWriter writer = new BufferedWriter(
|
||||
new OutputStreamWriter(
|
||||
new FileOutputStream(getCurrentLogFilePath(level), true), // 追加模式
|
||||
StandardCharsets.UTF_8 // 避免中文乱码
|
||||
)
|
||||
)) {
|
||||
System.out.print(logContent);
|
||||
writer.write(logContent.toString());
|
||||
writer.flush();
|
||||
} catch (IOException e) {
|
||||
System.err.println("日志写入失败:" + e.getMessage());
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼接多类型可变参数为单个字符串(自动转换任意类型为字符串,处理null)
|
||||
*
|
||||
* @param messages 1到多个任意类型参数(不可为空数组)
|
||||
* @return 拼接后的字符串
|
||||
*/
|
||||
private String joinMessages(Object... messages) {
|
||||
if (messages == null || messages.length == 0) {
|
||||
throw new IllegalArgumentException("日志消息至少需要1个参数");
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Object msg : messages) {
|
||||
sb.append(msg);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 异常堆栈信息转为字符串
|
||||
*/
|
||||
private String getStackTrace(Throwable throwable) {
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter pw = new PrintWriter(sw);
|
||||
throwable.printStackTrace(pw);
|
||||
return sw.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 动态修改日志路径
|
||||
*/
|
||||
public void setBaseLogPath(String baseLogPath) {
|
||||
this.baseLogPath = baseLogPath;
|
||||
initLogDir();
|
||||
}
|
||||
}
|
||||
@@ -58,70 +58,11 @@ jdbc:
|
||||
# Mysql 数据库配置
|
||||
type: mysql
|
||||
driver: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://127.0.0.1:13306/my_app?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=CONVERT_TO_NULL&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
|
||||
url: jdbc:mysql://192.168.31.182:13306/system?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=CONVERT_TO_NULL&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
|
||||
username: dream
|
||||
password: info_dream
|
||||
testSql: SELECT 1
|
||||
|
||||
# # Oracle 数据库配置
|
||||
# type: oracle
|
||||
# driver: oracle.jdbc.OracleDriver
|
||||
# url: jdbc:oracle:thin:@127.0.0.1:1521/orcl
|
||||
# username: jeesite
|
||||
# password: jeesite
|
||||
# testSql: SELECT 1 FROM DUAL
|
||||
|
||||
# # Sql Server 数据库配置(2008 版本,请打开 /modules/core/pom.xml 文件,替换为 SqlServer 2008 驱动并编译打包 core 模块)
|
||||
# type: mssql
|
||||
# driver: net.sourceforge.jtds.jdbc.Driver
|
||||
# url: jdbc:jtds:sqlserver://127.0.0.1:1433/jeesite
|
||||
# username: jeesite
|
||||
# password: jeesite
|
||||
# testSql: SELECT 1
|
||||
|
||||
# # Sql Server 数据库配置(2012 及以上版本,请打开 /modules/core/pom.xml 文件,替换为 SqlServer 2021 驱动并编译打包 core 模块)
|
||||
# type: mssql2012
|
||||
# driver: com.microsoft.sqlserver.jdbc.SQLServerDriver
|
||||
# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=jeesite;encrypt=true;trustServerCertificate=true
|
||||
# username: jeesite
|
||||
# password: jeesite
|
||||
# testSql: SELECT 1
|
||||
|
||||
# # PostgreSql 数据库配置
|
||||
# type: postgresql
|
||||
# driver: org.postgresql.Driver
|
||||
# url: jdbc:postgresql://127.0.0.1:5432/jeesite
|
||||
# username: jeesite
|
||||
# password: jeesite
|
||||
# testSql: SELECT 1
|
||||
|
||||
# # 达梦数据库配置,请勿使用 sysdba 用户
|
||||
# type: dameng
|
||||
# driver: dm.jdbc.driver.DmDriver
|
||||
# url: jdbc:dm://127.0.0.1:5236/jeesite5?schema=jeesite5
|
||||
# username: jeesite
|
||||
# password: jeesite123
|
||||
# testSql: SELECT 1 FROM DUAL
|
||||
|
||||
# # 人大金仓数据库配置
|
||||
# type: kingbase
|
||||
# driver: com.kingbase8.Driver
|
||||
# url: jdbc:kingbase8://127.0.0.1:54321/jeesite?currentSchema=jeesite&UseServerPrepare=false
|
||||
# username: jeesite
|
||||
# password: jeesite
|
||||
# testSql: SELECT 1 FROM DUAL
|
||||
|
||||
# # H2 数据库配置(请打开 /modules/core/pom.xml 文件,打开 H2 DB 驱动并编译打包 core 模块)
|
||||
# type: h2
|
||||
# driver: org.h2.Driver
|
||||
# url: jdbc:h2:~/jeesite-db/jeesite
|
||||
# username: jeesite
|
||||
# password: jeesite
|
||||
# testSql: SELECT 1
|
||||
|
||||
# 更多数据库的支持列表:
|
||||
# https://jeesite.com/docs/technology/#%E4%B8%83%E3%80%81%E5%B7%B2%E6%94%AF%E6%8C%81%E6%95%B0%E6%8D%AE%E5%BA%93
|
||||
|
||||
# 连接信息加密
|
||||
encrypt:
|
||||
|
||||
@@ -140,127 +81,6 @@ jdbc:
|
||||
# 最大激活连接数
|
||||
maxActive: 20
|
||||
|
||||
# # 连接超时参数,单位毫秒 (v5.5.2+)
|
||||
# connectTimeout: ~
|
||||
# socketTimeout: ~
|
||||
#
|
||||
# # 查询超时时间,事务超时时间 (v5.7.1+)
|
||||
# queryTimeout: ~
|
||||
# transactionQueryTimeout: ~
|
||||
#
|
||||
# # 获取连接等待超时时间,单位毫秒(1分钟)(4.0.6+)
|
||||
# maxWait: 60000
|
||||
#
|
||||
# # 连接失败后中断,默认为 false 时,会一直尝试连接,为 true 时,自动中断尝试(v5.9.0+)
|
||||
# breakAfterAcquireFailure: false
|
||||
#
|
||||
# # 从池中取出和归还连接前进行检验,如果检验失败,则从池中去除连接并尝试取出另一个(4.0.6+)
|
||||
# testOnBorrow: false
|
||||
# testOnReturn: false
|
||||
#
|
||||
# # 间隔多久才进行一次检测,检测需要关闭的空闲连接,单位毫秒(1分钟)(4.0.6+)
|
||||
# timeBetweenEvictionRunsMillis: 60000
|
||||
#
|
||||
# # 一个连接在池中最小空闲的时间,单位毫秒(20分钟)(4.0.6+)
|
||||
# minEvictableIdleTimeMillis: 1200000
|
||||
# # 一个连接在池中最大空闲的时间,单位毫秒(30分钟)(4.1.2+)
|
||||
# maxEvictableIdleTimeMillis: 1800000
|
||||
#
|
||||
# # 连接池中的minIdle数量以内的连接,空闲时间超过minEvictableIdleTimeMillis,则会执行keepAlive操作(4.1.8+)
|
||||
# keepAlive: false
|
||||
#
|
||||
# # 是否自动回收泄露的连接和超时时间,单位秒(35分钟)(4.0.6+)
|
||||
# removeAbandoned: false
|
||||
# removeAbandonedTimeout: 2100
|
||||
#
|
||||
# # 是否缓存 PreparedStatement 对象的最大数量(4.1.5+)
|
||||
# maxPoolPreparedStatementPerConnectionSize: ~
|
||||
#
|
||||
# # 设置连接属性,可获取到表的 remark (备注)
|
||||
# remarksReporting: false
|
||||
|
||||
# # 读写分离配置(专业版)v4.3.0
|
||||
# readwriteSplitting:
|
||||
# # 读库的数据源名称列表(默认数据源)
|
||||
# readDataSourceNames: ds_read_01, ds_read_02
|
||||
# # 负载均衡算法(ROUND_ROBIN轮询、RANDOM随机、自定义类名)
|
||||
# loadBalancerAlgorithm: RANDOM
|
||||
#
|
||||
# # 多数据源名称列表,多个用逗号隔开,使用方法:@MyBatisDao(dataSourceName="ds2")
|
||||
# # v5.11.1+ 支持 dataSourceNames 免配置,自动读取 jdbc.数据源名.type 的属性
|
||||
# dataSourceNames: ds_read_01, ds_read_02
|
||||
#
|
||||
# # 默认数据源的从库01
|
||||
# ds_read_01:
|
||||
# type: mysql
|
||||
# driver: com.mysql.cj.jdbc.Driver
|
||||
# url: jdbc:mysql://127.0.0.1:3306/jeesite_test?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=CONVERT_TO_NULL&serverTimezone=Asia/Shanghai
|
||||
# username: root
|
||||
# password: 123456
|
||||
# testSql: SELECT 1
|
||||
# pool:
|
||||
# init: 1
|
||||
# minIdle: 3
|
||||
# maxActive: 20
|
||||
#
|
||||
# # 默认数据源的从库02
|
||||
# ds_read_02:
|
||||
# type: mysql
|
||||
# driver: com.mysql.cj.jdbc.Driver
|
||||
# url: jdbc:mysql://127.0.0.1:3306/jeesite_test2?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=CONVERT_TO_NULL&serverTimezone=Asia/Shanghai
|
||||
# username: root
|
||||
# password: 123456
|
||||
# testSql: SELECT 1
|
||||
# pool:
|
||||
# init: 1
|
||||
# minIdle: 3
|
||||
# maxActive: 20
|
||||
|
||||
# # 多数据源名称列表,多个用逗号隔开,使用方法:@MyBatisDao(dataSourceName="ds2")
|
||||
# # v5.11.1+ 支持 dataSourceNames 免配置,自动读取 jdbc.数据源名.type 的属性
|
||||
# dataSourceNames: ds2
|
||||
#
|
||||
# # 多数据源配置:ds2
|
||||
# ds2:
|
||||
# type: mysql
|
||||
# driver: com.mysql.cj.jdbc.Driver
|
||||
# url: jdbc:mysql://127.0.0.1:3306/jeesite2?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=CONVERT_TO_NULL&serverTimezone=Asia/Shanghai
|
||||
# username: root
|
||||
# password: 123456
|
||||
# testSql: SELECT 1
|
||||
# # 其它数据源支持密码加密
|
||||
# encrypt:
|
||||
# username: false
|
||||
# password: true
|
||||
# # 其它数据源支持连接池设置
|
||||
# pool:
|
||||
# init: 1
|
||||
# minIdle: 3
|
||||
# maxActive: 20
|
||||
# # 其它数据源支持读写分离
|
||||
# readwriteSplitting:
|
||||
# readDataSourceNames: ~
|
||||
# loadBalancerAlgorithm: RANDOM
|
||||
|
||||
# # 数据源映射(Dao类名 = 数据源名称),优先于 @MyBatisDao(dataSourceName="ds2") 设置 v4.3.0
|
||||
# # Dao类名,不仅支持某个具体 Dao类名,还支持 Dao 里的某个方法指定数据源名称,还支持包路径指定数据源等
|
||||
# # 数据源名指定 {dynamic} 时支持动态,相当于 @MyBatisDao(dataSourceName=DataSourceHolder.DYNAMIC)
|
||||
# # 数据源支持指定变量 {corpCode}、 {userCode}、{userCache中的Key名}、{yml或sys_config中的Key名}
|
||||
# # 从上到下,先匹配先受用规则,默认数据源名为 default 扩展数据源为 dataSourceNames 列表里自定义的名字
|
||||
# mybatisDaoAndDataSourceMappings: |
|
||||
# TestDataChildDao = ds2
|
||||
# EmpUserDao.findList = ds2
|
||||
# com.jeesite.modules.sys. = default
|
||||
# com.jeesite.modules.filemanager. = ds2
|
||||
|
||||
# # 表名和字段名(前缀|后缀)是否强制大写(v4.1.8+)
|
||||
# tableAndColumn:
|
||||
# prefixSuffix: "`|`"
|
||||
# forceUpperCase: true
|
||||
#
|
||||
# # 表名前缀
|
||||
# tablePrefix: js_
|
||||
|
||||
#======================================#
|
||||
#========== Spring settings ===========#
|
||||
#======================================#
|
||||
|
||||
Reference in New Issue
Block a user