1 changed files with 85 additions and 0 deletions
@ -0,0 +1,85 @@ |
|||||
|
# 应用程序配置说明 |
||||
|
|
||||
|
## 配置文件结构 |
||||
|
应用程序使用以下配置文件: |
||||
|
- `appsettings.json` - 基础配置文件 |
||||
|
- `appsettings.Development.json` - 开发环境配置 |
||||
|
- `appsettings.Production.json` - 生产环境配置 |
||||
|
|
||||
|
## 主要配置项说明 |
||||
|
|
||||
|
### 数据库配置 |
||||
|
```json |
||||
|
{ |
||||
|
"ConnectionStrings": { |
||||
|
"DefaultConnection": "Server=localhost;Database=CellularManagement;Trusted_Connection=True;MultipleActiveResultSets=true" |
||||
|
} |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
### JWT配置 |
||||
|
```json |
||||
|
{ |
||||
|
"JwtSettings": { |
||||
|
"SecretKey": "your-secret-key", |
||||
|
"Issuer": "CellularManagement", |
||||
|
"Audience": "CellularManagement", |
||||
|
"ExpiryInMinutes": 60 |
||||
|
} |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
### WebSocket配置 |
||||
|
```json |
||||
|
{ |
||||
|
"WebSocketSettings": { |
||||
|
"Path": "/ws", |
||||
|
"KeepAliveInterval": 120, |
||||
|
"ReceiveBufferSize": 4096, |
||||
|
"MaxConnections": 1000, |
||||
|
"EnableCompression": true |
||||
|
} |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
### 缓存配置 |
||||
|
```json |
||||
|
{ |
||||
|
"CacheSettings": { |
||||
|
"SlidingExpiration": 30, |
||||
|
"AbsoluteExpiration": 60 |
||||
|
} |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
### 日志配置 |
||||
|
```json |
||||
|
{ |
||||
|
"Logging": { |
||||
|
"LogLevel": { |
||||
|
"Default": "Information", |
||||
|
"Microsoft": "Warning", |
||||
|
"Microsoft.Hosting.Lifetime": "Information" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
## 环境变量配置 |
||||
|
以下环境变量可以在不同环境中覆盖配置文件中的设置: |
||||
|
|
||||
|
- `ASPNETCORE_ENVIRONMENT` - 设置运行环境(Development/Production) |
||||
|
- `ConnectionStrings__DefaultConnection` - 数据库连接字符串 |
||||
|
- `JwtSettings__SecretKey` - JWT密钥 |
||||
|
- `WebSocketSettings__MaxConnections` - WebSocket最大连接数 |
||||
|
|
||||
|
## 配置优先级 |
||||
|
1. 环境变量 |
||||
|
2. 命令行参数 |
||||
|
3. 环境特定配置文件(appsettings.{Environment}.json) |
||||
|
4. 基础配置文件(appsettings.json) |
||||
|
|
||||
|
## 安全注意事项 |
||||
|
1. 生产环境中不要将敏感信息(如密钥、连接字符串)直接写入配置文件 |
||||
|
2. 使用环境变量或安全的密钥管理服务来存储敏感信息 |
||||
|
3. 确保配置文件不会被提交到版本控制系统 |
||||
Loading…
Reference in new issue