feat: 新增 Spring Boot 3 客户端 SDK 及 demo

- 新增 kenaito-conf-springboot3-client,支持配置拉取、增量同步、@Value/@ConfigurationProperties 动态刷新和本地缓存

- 新增 kenaito-conf-springboot3-client-demo(端口 8084)及 Dockerfile.springboot3

- 完善中英文 README、Docker 部署文档,修正 Spring Boot 2 客户端配置键名与 demo 端口说明

- 修复增量同步将服务端 code=0 成功响应误判为错误的问题
This commit is contained in:
2026-08-22 21:02:15 +08:00
parent 5f67274e3f
commit 182765e4a0
28 changed files with 2566 additions and 57 deletions
+24 -21
View File
@@ -38,28 +38,28 @@ mvn clean install
```properties
# 配置中心地址
kenaito.configcenter.base-url=http://localhost:8080
kenaito.config.baseUrl=http://localhost:8080
# 应用名称(必填)
kenaito.configcenter.app-name=my-app
kenaito.config.appName=my-app
# 环境(dev/daily/prod)
kenaito.configcenter.env=daily
kenaito.config.profile=daily
# 配置版本
kenaito.configcenter.version=latest
kenaito.config.version=latest
# 认证令牌(可选)
kenaito.configcenter.token=your-token
kenaito.config.token=your-token
# 是否启用远程配置(默认 true)
kenaito.configcenter.enabled=true
kenaito.config.enabled=true
# 同步间隔(秒,默认 10)
kenaito.configcenter.sync-interval=10
# 同步间隔(秒,默认 60)
kenaito.config.sync-interval-seconds=10
# 敏感配置键(用于日志脱敏,可选)
kenaito.configcenter.sensitive-keys=password,secret,key,token
# 是否忽略业务组全局配置(默认 false)
kenaito.config.global-ignore=false
```
### 2. 使用 @Value 注入配置
@@ -124,14 +124,17 @@ public class DatabaseProperties {
| 配置项 | 说明 | 默认值 | 必填 |
|--------|------|--------|------|
| `kenaito.configcenter.base-url` | 配置中心地址 | - | 是 |
| `kenaito.configcenter.app-name` | 应用名称 | - | 是 |
| `kenaito.configcenter.env` | 环境标识 | `dev` | 否 |
| `kenaito.configcenter.version` | 配置版本 | `latest` | 否 |
| `kenaito.configcenter.token` | 认证令牌 | 空 | 否 |
| `kenaito.configcenter.enabled` | 是否启用 | `true` | 否 |
| `kenaito.configcenter.sync-interval` | 同步间隔(秒) | `10` | 否 |
| `kenaito.configcenter.sensitive-keys` | 敏感键(日志脱敏) | 空 | 否 |
| `kenaito.config.baseUrl` | 配置中心地址 | - | 是 |
| `kenaito.config.appName` | 应用名称 | `spring.application.name` | 是 |
| `kenaito.config.profile` | 环境标识 | `dev` | 否 |
| `kenaito.config.version` | 配置版本 | `latest` | 否 |
| `kenaito.config.token` | 认证令牌 | 空 | 否 |
| `kenaito.config.enabled` | 是否启用 | `true` | 否 |
| `kenaito.config.sync-interval-seconds` | 同步间隔(秒) | `60` | 否 |
| `kenaito.config.global-ignore` | 忽略业务组全局配置 | `false` | 否 |
| `kenaito.configcenter.local-storage-dir` | 本地缓存目录 | 应用工作目录 | 否 |
> Spring Boot 2 客户端读取的是驼峰形式的 `baseUrl` / `appName`;敏感键固定为 `password`、`passwd`、`key`、`secret`、`token`、`credentials`,暂不支持自定义。
## 自动配置说明
@@ -152,12 +155,12 @@ mvn spring-boot:run
```
Demo 默认配置:
- 端口:8083
- 应用名称:`kenaito-springboot2-demo`
- 端口:8081
- 应用名称:`kenaito-springboot-demo`
- 环境:`daily`
- 配置中心地址:`http://localhost:8080`
访问 `http://localhost:8083/config` 查看当前配置。
访问 `http://localhost:8081/` 或 `http://localhost:8081/configprops` 查看当前配置。
## 注意事项
+24 -21
View File
@@ -36,28 +36,28 @@ Add config center connection parameters in `application.properties`:
```properties
# Config center URL
kenaito.configcenter.base-url=http://localhost:8080
kenaito.config.baseUrl=http://localhost:8080
# Application name (required)
kenaito.configcenter.app-name=my-app
kenaito.config.appName=my-app
# Environment (dev/daily/prod)
kenaito.configcenter.env=daily
kenaito.config.profile=daily
# Config version
kenaito.configcenter.version=latest
kenaito.config.version=latest
# Auth token (optional)
kenaito.configcenter.token=your-token
kenaito.config.token=your-token
# Whether to enable remote config (default true)
kenaito.configcenter.enabled=true
kenaito.config.enabled=true
# Sync interval in seconds (default 10)
kenaito.configcenter.sync-interval=10
# Sync interval in seconds (default 60)
kenaito.config.sync-interval-seconds=10
# Sensitive config keys (for log masking, optional)
kenaito.configcenter.sensitive-keys=password,secret,key,token
# Ignore business group global configs (default false)
kenaito.config.global-ignore=false
```
### 2. Inject Configs with @Value
@@ -122,14 +122,17 @@ public class DatabaseProperties {
| Property | Description | Default | Required |
|----------|-------------|---------|----------|
| `kenaito.configcenter.base-url` | Config center URL | - | Yes |
| `kenaito.configcenter.app-name` | Application name | - | Yes |
| `kenaito.configcenter.env` | Environment | `dev` | No |
| `kenaito.configcenter.version` | Config version | `latest` | No |
| `kenaito.configcenter.token` | Auth token | Empty | No |
| `kenaito.configcenter.enabled` | Whether to enable | `true` | No |
| `kenaito.configcenter.sync-interval` | Sync interval (seconds) | `10` | No |
| `kenaito.configcenter.sensitive-keys` | Sensitive keys (log masking) | Empty | No |
| `kenaito.config.baseUrl` | Config center URL | - | Yes |
| `kenaito.config.appName` | Application name | `spring.application.name` | Yes |
| `kenaito.config.profile` | Environment | `dev` | No |
| `kenaito.config.version` | Config version | `latest` | No |
| `kenaito.config.token` | Auth token | Empty | No |
| `kenaito.config.enabled` | Whether to enable | `true` | No |
| `kenaito.config.sync-interval-seconds` | Sync interval (seconds) | `60` | No |
| `kenaito.config.global-ignore` | Ignore business group global configs | `false` | No |
| `kenaito.configcenter.local-storage-dir` | Local cache directory | Application working directory | No |
> The Spring Boot 2 client reads the camel-case `baseUrl` / `appName` keys. Sensitive keys are fixed to `password`, `passwd`, `key`, `secret`, `token`, `credentials` and cannot be customized.
## Auto Configuration
@@ -150,12 +153,12 @@ mvn spring-boot:run
```
Demo defaults:
- Port: 8083
- App name: `kenaito-springboot2-demo`
- Port: 8081
- App name: `kenaito-springboot-demo`
- Environment: `daily`
- Config center URL: `http://localhost:8080`
Visit `http://localhost:8083/config` to view current configs.
Visit `http://localhost:8081/` or `http://localhost:8081/configprops` to view current configs.
## Notes