From f37696f51cf642a8dbf043fabb90568bdbf295e7 Mon Sep 17 00:00:00 2001 From: "gui.h" Date: Sun, 14 Jul 2024 16:49:05 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9A=90=E8=97=8F=E6=95=8F=E6=84=9F=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Extensions/PersistenceCollectionExtensions.cs | 8 +++++++- src/OpenTask.WebApi/Properties/launchSettings.json | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/OpenTask.Persistence/Extensions/PersistenceCollectionExtensions.cs b/src/OpenTask.Persistence/Extensions/PersistenceCollectionExtensions.cs index 3017328..13eba51 100644 --- a/src/OpenTask.Persistence/Extensions/PersistenceCollectionExtensions.cs +++ b/src/OpenTask.Persistence/Extensions/PersistenceCollectionExtensions.cs @@ -11,8 +11,10 @@ using Microsoft.Extensions.Logging; using OpenTask.Persistence.Contexts; using OpenTask.Persistence.Models; +using Org.BouncyCastle.Security; using System.Reflection; using System.Runtime.Loader; +using System.Text.RegularExpressions; namespace OpenTask.Persistence.Extensions { @@ -25,8 +27,12 @@ public static IServiceCollection AddDefalutPersistence(this IServiceCollection s var logger = loggerFactory.CreateLogger("PersistenceCollectionExtensions"); string? constr = configuration["ConnectionStrings:Core"]; + if (constr == null) + { + throw new InvalidParameterException("未配置数据库连接字符串"); + } - logger.LogInformation(constr); + logger.LogInformation($"db: {Regex.Replace(constr, @"(?<=password=).*?(?=;|$)", "******")}"); _ = services.AddDapperdbContext(options => { diff --git a/src/OpenTask.WebApi/Properties/launchSettings.json b/src/OpenTask.WebApi/Properties/launchSettings.json index 1b76065..5fa0f20 100644 --- a/src/OpenTask.WebApi/Properties/launchSettings.json +++ b/src/OpenTask.WebApi/Properties/launchSettings.json @@ -16,7 +16,7 @@ "launchUrl": "swagger", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development", - "ConnectionStrings__Core": "server=localhost;Port=3306;user id=root;database=open_task;pooling=true;password=OPEN_TASK_!@#" + //"ConnectionStrings__Core": "server=127.0.0.1;Port=3306;user id=root;database=open_task;pooling=true;password=OPEN_TASK_!@#" }, "dotnetRunMessages": true, "applicationUrl": "https://localhost:7254;http://localhost:5223"