From b1a311cf8409a971c1c740c32e9d5227a9978d9f Mon Sep 17 00:00:00 2001 From: fuenmao <980740792@qq.com> Date: Mon, 21 Sep 2026 14:20:36 +0800 Subject: [PATCH] config: use direct MySQL connection string --- .gitignore | 3 +-- .../Configuration/Database.local.example.json | 10 ---------- Evergreen.Health.Api/Program.cs | 6 ------ .../Configuration/Database.json | 2 +- README.md | 7 +++---- 5 files changed, 5 insertions(+), 23 deletions(-) delete mode 100644 Evergreen.Health.Api/Configuration/Database.local.example.json diff --git a/.gitignore b/.gitignore index 1911d33..ec14a38 100644 --- a/.gitignore +++ b/.gitignore @@ -11,8 +11,7 @@ logs/ *.user *.suo -# Local secrets and runtime files -**/Configuration/Database.local.json +# Runtime files **/wwwroot/upload/ *.db *.db-shm diff --git a/Evergreen.Health.Api/Configuration/Database.local.example.json b/Evergreen.Health.Api/Configuration/Database.local.example.json deleted file mode 100644 index c80c2ca..0000000 --- a/Evergreen.Health.Api/Configuration/Database.local.example.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "DbConnection": { - "ConnectionConfigs": [ - { - "DbType": "MySqlConnector", - "ConnectionString": "Server=127.0.0.1;Port=3306;Database=evergreen_health;User ID=root;Password=CHANGE_ME;CharSet=utf8mb4;SslMode=None;Pooling=true;Connection Timeout=30" - } - ] - } -} diff --git a/Evergreen.Health.Api/Program.cs b/Evergreen.Health.Api/Program.cs index 549fdd4..e67ee4c 100644 --- a/Evergreen.Health.Api/Program.cs +++ b/Evergreen.Health.Api/Program.cs @@ -10,12 +10,6 @@ public class WebComponent : IWebComponent { public void Load(WebApplicationBuilder builder, ComponentContext componentContext) { - // 本机数据库配置。该文件已加入 .gitignore,仅用于保存真实连接信息。 - builder.Configuration.AddJsonFile( - "Configuration/Database.local.json", - optional: true, - reloadOnChange: true); - // 设置日志过滤 builder.Logging.AddFilter((provider, category, logLevel) => { diff --git a/Evergreen.Health.Application/Configuration/Database.json b/Evergreen.Health.Application/Configuration/Database.json index 82254f8..d51b627 100644 --- a/Evergreen.Health.Application/Configuration/Database.json +++ b/Evergreen.Health.Application/Configuration/Database.json @@ -10,7 +10,7 @@ //"ConfigId": "1300000000001", // 默认库标识-禁止修改 "DbType": "MySqlConnector", // MySql、SqlServer、Sqlite、Oracle、PostgreSQL、Dm、Kdbndp、Oscar、MySqlConnector、Access、OpenGauss、QuestDB、HG、ClickHouse、GBase、Odbc、Custom "DbNickName": "系统库", - "ConnectionString": "Server=127.0.0.1;Port=3306;Database=evergreen_health;Uid=root;Pwd=CHANGE_ME;SslMode=None;AllowLoadLocalInfile=true;AllowUserVariables=true;CharSet=utf8mb4;", // 本地开发MySQL:请替换Uid和Pwd + "ConnectionString": "AllowLoadLocalInfile=true;Server=116.168.197.2;User ID=admin;Password=so^867z$4S;Port=16306;Database=evergreen_health;CharSet=utf8mb4;Pooling=true;SslMode=None;min pool size=1;Connection Timeout=30;Pooling=false", // 本地开发MySQL:请替换Uid和Pwd //"ConnectionString": "PORT=5432;DATABASE=xxx;HOST=localhost;PASSWORD=xxx;USER ID=xxx", // PostgreSQL //"ConnectionString": "Server=localhost;Database=xxx;Uid=xxx;Pwd=xxx;SslMode=None;AllowLoadLocalInfile=true;AllowUserVariables=true;", // MySql, //"ConnectionString": "User Id=xxx; Password=xxx; Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORCL)))", // Oracle diff --git a/README.md b/README.md index a09b822..90fb566 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,9 @@ ## 本地启动 -1. 复制 `Evergreen.Health.Api/Configuration/Database.local.example.json` 为 `Database.local.json`。 -2. 修改 `Database.local.json` 中的 MySQL 连接字符串。该文件已被 Git 忽略,不会提交密码。 -3. 执行 `dotnet restore Evergreen.Health.sln`。 -4. 执行 `dotnet run --project Evergreen.Health.Api/Evergreen.Health.Api.csproj`。 +1. 修改 `Evergreen.Health.Application/Configuration/Database.json` 中的 MySQL 连接字符串。 +2. 执行 `dotnet restore Evergreen.Health.sln`。 +3. 执行 `dotnet run --project Evergreen.Health.Api/Evergreen.Health.Api.csproj`。 ## 健康业务接口