# springboot-x-example
**Repository Path**: techzhi/springboot-x-example
## Basic Information
- **Project Name**: springboot-x-example
- **Description**: 常见的springboot组件集成测试
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: main
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2025-09-07
- **Last Updated**: 2025-09-07
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# Springboot X Example
这里会介绍常见的自研公共模块的集成使用说明。
# tally-common-tidb
本模块提供了完整的TiDB数据源集成功能,支持动态加载、连接池管理、操作工具等特性。
## 🏗️ 架构设计
```
tally-common-tidb/
├── src/main/java/com/nvxclouds/baize/tally/common/tidb/
│ ├── config/ # 配置管理
│ │ └── TiDBConfigManager.java
│ ├── pool/ # 连接池管理
│ │ └── TiDBConnectionPoolManager.java
│ ├── utils/ # 操作工具类
│ │ └── TiDBOperationUtils.java
│ ├── loader/ # 动态加载器
│ │ └── TiDBUtilsLoader.java
│ ├── service/ # 统一服务接口
│ │ └── TiDBService.java
│ └── model/ # 数据模型
│ ├── TableColumnInfo.java
│ ├── QueryRequest.java
│ └── BatchRequest.java
├── pom.xml
└── README.md
```
## ⚙️ 配置说明
### 添加依赖
在需要使用TiDB功能的模块中添加依赖:
```xml
com.nvxclouds.baize.tally
tally-common-tidb
3.2.0-springboot2-jdk8-SNAPSHOT
```
## 🚀 快速开始
### 1. 启用TiDB
修改配置文件application.yaml启用TiDB:
```yaml
# TiDB数据源配置
tidb:
# 是否开启TiDB
enabled: true
# 连接信息
config:
host: 192.168.50.9
port: 4000
database: jdf
username: root
password: Root_123
charset: utf8
timezone: Asia/Shanghai
# 连接参数
properties:
useUnicode: "true"
characterEncoding: "utf8"
connectionCollation: "utf8_general_ci"
useSSL: "false"
allowPublicKeyRetrieval: "true"
rewriteBatchedStatements: "true"
allowMultiQueries: "true"
useCompression: "true"
# TiDB专用配置
tidb_isolation_read_engines: "tiflash,tikv"
tidb_allow_batch_cop: "1"
# 连接池配置
pool:
maximum-pool-size: 20
minimum-idle: 5
connection-timeout: 30000
idle-timeout: 600000
max-lifetime: 1800000
pool-name: TiDB-HikariCP
leak-detection-threshold: 60000
auto-commit: true
# 安全配置
security:
encrypt-password: true
enable-ssl: false
validation-timeout: 5000
connection-test-query: "SELECT 1"
```
### 2. 基本使用
```java
@Autowired
private TiDBService tidbService;
// 查询数据
List