diff --git a/aspnet-core/LINGYUN.MicroService.SingleProject.sln b/aspnet-core/LINGYUN.MicroService.SingleProject.sln index 2f5af7160..219e3f2f7 100644 --- a/aspnet-core/LINGYUN.MicroService.SingleProject.sln +++ b/aspnet-core/LINGYUN.MicroService.SingleProject.sln @@ -428,6 +428,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ..\NuGet.Config = ..\NuGet.Config ..\README.en.md = ..\README.en.md ..\README.md = ..\README.md + ..\docs\startup-aio-readme.md = ..\docs\startup-aio-readme.md EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dapr", "dapr", "{FD9F5933-FDE5-4504-99BF-9050E0435C6D}" @@ -1288,10 +1289,10 @@ Global {F94E77C1-61E0-4FE8-9ECD-10A0102342E9}.Debug|Any CPU.Build.0 = Debug|Any CPU {F94E77C1-61E0-4FE8-9ECD-10A0102342E9}.Release|Any CPU.ActiveCfg = Release|Any CPU {F94E77C1-61E0-4FE8-9ECD-10A0102342E9}.Release|Any CPU.Build.0 = Release|Any CPU - {83D2F8F2-82C7-4919-9B65-D0FBF0B5324C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {83D2F8F2-82C7-4919-9B65-D0FBF0B5324C}.Release|Any CPU.Build.0 = Release|Any CPU {83D2F8F2-82C7-4919-9B65-D0FBF0B5324C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {83D2F8F2-82C7-4919-9B65-D0FBF0B5324C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {83D2F8F2-82C7-4919-9B65-D0FBF0B5324C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {83D2F8F2-82C7-4919-9B65-D0FBF0B5324C}.Release|Any CPU.Build.0 = Release|Any CPU {CAEF3248-527D-48B7-9C98-929AC573C381}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CAEF3248-527D-48B7-9C98-929AC573C381}.Debug|Any CPU.Build.0 = Debug|Any CPU {CAEF3248-527D-48B7-9C98-929AC573C381}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/aspnet-core/migrations/LY.MicroService.Applications.Single.DbMigrator/appsettings.json b/aspnet-core/migrations/LY.MicroService.Applications.Single.DbMigrator/appsettings.json index 2b17de592..daded80e0 100644 --- a/aspnet-core/migrations/LY.MicroService.Applications.Single.DbMigrator/appsettings.json +++ b/aspnet-core/migrations/LY.MicroService.Applications.Single.DbMigrator/appsettings.json @@ -3,7 +3,8 @@ "Kind": "Local" }, "ConnectionStrings": { - "Default": "Server=127.0.0.1;Database=Platform-V70;User Id=root;Password=123456;SslMode=None" + // "Default": "Server=127.0.0.1;Database=Platform-V70;User Id=root;Password=123456;SslMode=None"//MySql + "Default": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;SslMode=Prefer"//PostgreSql }, "StringEncryption": { "DefaultPassPhrase": "s46c5q55nxpeS8Ra", diff --git a/aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore/SingleDbMigrationService.cs b/aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore/SingleDbMigrationService.cs index a02a8e3aa..1247b3499 100644 --- a/aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore/SingleDbMigrationService.cs +++ b/aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore/SingleDbMigrationService.cs @@ -1,101 +1,101 @@ -using LINGYUN.Abp.Saas.Tenants; -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; -using System; -using System.Linq; -using System.Threading.Tasks; -using Volo.Abp.Data; -using Volo.Abp.DependencyInjection; -using Volo.Abp.DistributedLocking; -using Volo.Abp.EntityFrameworkCore; -using Volo.Abp.EntityFrameworkCore.Migrations; -using Volo.Abp.EventBus.Distributed; -using Volo.Abp.MultiTenancy; -using Volo.Abp.Uow; - -namespace LY.MicroService.Applications.Single.EntityFrameworkCore; - -public class SingleDbMigrationService : EfCoreRuntimeDatabaseMigratorBase, ITransientDependency -{ - protected IDataSeeder DataSeeder { get; } - protected ITenantRepository TenantRepository { get; } - public SingleDbMigrationService( - IUnitOfWorkManager unitOfWorkManager, - IServiceProvider serviceProvider, - ICurrentTenant currentTenant, - IAbpDistributedLock abpDistributedLock, - IDistributedEventBus distributedEventBus, - ILoggerFactory loggerFactory, - IDataSeeder dataSeeder, - ITenantRepository tenantRepository) - : base("SingleDbMigrator", unitOfWorkManager, serviceProvider, currentTenant, abpDistributedLock, distributedEventBus, loggerFactory) - { - DataSeeder = dataSeeder; - TenantRepository = tenantRepository; - } - protected async override Task LockAndApplyDatabaseMigrationsAsync() - { - await base.LockAndApplyDatabaseMigrationsAsync(); - - var tenants = await TenantRepository.GetListAsync(); - foreach (var tenant in tenants.Where(x => x.IsActive)) - { - Logger.LogInformation($"Trying to acquire the distributed lock for database migration: {DatabaseName} with tenant: {tenant.Name}."); - - var schemaMigrated = false; - - await using (var handle = await DistributedLock.TryAcquireAsync("DatabaseMigration_" + DatabaseName + "_Tenant" + tenant.Id.ToString())) - { - if (handle is null) - { - Logger.LogInformation($"Distributed lock could not be acquired for database migration: {DatabaseName} with tenant: {tenant.Name}. Operation cancelled."); - return; - } - - Logger.LogInformation($"Distributed lock is acquired for database migration: {DatabaseName} with tenant: {tenant.Name}..."); - - using (CurrentTenant.Change(tenant.Id)) - { - // Create database tables if needed - using var uow = UnitOfWorkManager.Begin(requiresNew: true, isTransactional: false); - var dbContext = await ServiceProvider - .GetRequiredService>() - .GetDbContextAsync(); - - var pendingMigrations = await dbContext - .Database - .GetPendingMigrationsAsync(); - - if (pendingMigrations.Any()) - { - await dbContext.Database.MigrateAsync(); - schemaMigrated = true; - } - - await uow.CompleteAsync(); - - await SeedAsync(); - - if (schemaMigrated || AlwaysSeedTenantDatabases) - { - await DistributedEventBus.PublishAsync( - new AppliedDatabaseMigrationsEto - { - DatabaseName = DatabaseName, - TenantId = tenant.Id - } - ); - } - } - } - - Logger.LogInformation($"Distributed lock has been released for database migration: {DatabaseName} with tenant: {tenant.Name}..."); - } - } - - protected async override Task SeedAsync() - { - await DataSeeder.SeedAsync(CurrentTenant.Id); - } +using LINGYUN.Abp.Saas.Tenants; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using System; +using System.Linq; +using System.Threading.Tasks; +using Volo.Abp.Data; +using Volo.Abp.DependencyInjection; +using Volo.Abp.DistributedLocking; +using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.EntityFrameworkCore.Migrations; +using Volo.Abp.EventBus.Distributed; +using Volo.Abp.MultiTenancy; +using Volo.Abp.Uow; + +namespace LY.MicroService.Applications.Single.EntityFrameworkCore; + +public class SingleDbMigrationService : EfCoreRuntimeDatabaseMigratorBase, ITransientDependency +{ + protected IDataSeeder DataSeeder { get; } + protected ITenantRepository TenantRepository { get; } + public SingleDbMigrationService( + IUnitOfWorkManager unitOfWorkManager, + IServiceProvider serviceProvider, + ICurrentTenant currentTenant, + IAbpDistributedLock abpDistributedLock, + IDistributedEventBus distributedEventBus, + ILoggerFactory loggerFactory, + IDataSeeder dataSeeder, + ITenantRepository tenantRepository) + : base("SingleDbMigrator", unitOfWorkManager, serviceProvider, currentTenant, abpDistributedLock, distributedEventBus, loggerFactory) + { + DataSeeder = dataSeeder; + TenantRepository = tenantRepository; + } + protected async override Task LockAndApplyDatabaseMigrationsAsync() + { + await base.LockAndApplyDatabaseMigrationsAsync(); + + var tenants = await TenantRepository.GetListAsync(); + foreach (var tenant in tenants.Where(x => x.IsActive)) + { + Logger.LogInformation($"Trying to acquire the distributed lock for database migration: {DatabaseName} with tenant: {tenant.Name}."); + + var schemaMigrated = false; + + await using (var handle = await DistributedLock.TryAcquireAsync("DatabaseMigration_" + DatabaseName + "_Tenant" + tenant.Id.ToString())) + { + if (handle is null) + { + Logger.LogInformation($"Distributed lock could not be acquired for database migration: {DatabaseName} with tenant: {tenant.Name}. Operation cancelled."); + return; + } + + Logger.LogInformation($"Distributed lock is acquired for database migration: {DatabaseName} with tenant: {tenant.Name}..."); + + using (CurrentTenant.Change(tenant.Id)) + { + // Create database tables if needed + using var uow = UnitOfWorkManager.Begin(requiresNew: true, isTransactional: false); + var dbContext = await ServiceProvider + .GetRequiredService>() + .GetDbContextAsync(); + + var pendingMigrations = await dbContext + .Database + .GetPendingMigrationsAsync(); + + if (pendingMigrations.Any()) + { + await dbContext.Database.MigrateAsync(); + schemaMigrated = true; + } + + await uow.CompleteAsync(); + + await SeedAsync(); + + if (schemaMigrated || AlwaysSeedTenantDatabases) + { + await DistributedEventBus.PublishAsync( + new AppliedDatabaseMigrationsEto + { + DatabaseName = DatabaseName, + TenantId = tenant.Id + } + ); + } + } + } + + Logger.LogInformation($"Distributed lock has been released for database migration: {DatabaseName} with tenant: {tenant.Name}..."); + } + } + + protected async override Task SeedAsync() + { + await DataSeeder.SeedAsync(CurrentTenant.Id); + } } \ No newline at end of file diff --git a/docs/startup-aio-readme.en.md b/docs/startup-aio-readme.en.md new file mode 100644 index 000000000..baa9bb741 --- /dev/null +++ b/docs/startup-aio-readme.en.md @@ -0,0 +1,348 @@ +# Monolithic Service Startup Guide + +English | [简体中文](startup-aio-readme.md) + +## Table of Contents + +- [Requirements](#requirements) +- [Project Compilation](#project-compilation) +- [Environment Configuration](#environment-configuration) + - [Required Configuration](#required-configuration) + - [Optional Configuration](#optional-configuration) +- [Database Initialization](#database-initialization) +- [Service Startup](#service-startup) +- [Configuration Details](#configuration-details) + +## Requirements + +- .NET 8.0 SDK +- Database (support any of the following): + - PostgreSQL + - MySQL + - SQL Server (coming soon) +- Redis +- Docker (optional) + +## Project Compilation + +1. Ensure .NET 8.0 SDK is installed +2. Execute the following command in the project root directory to compile the entire project: + +```shell +./build/build-aspnetcore-release.ps1 +``` + +3. Open the `LY.MicroService.Applications.Single` solution in your IDE for debugging or publishing + +## Environment Configuration + +### Required Configuration + +#### 1. Database Configuration + +Multiple databases are supported. Here are configuration examples for each: + +##### PostgreSQL + +```shell +# Start PostgreSQL using Docker +docker run -d --name postgres \ + -p 5432:5432 \ + -e POSTGRES_PASSWORD=postgres \ + -e PGDATA=/var/lib/postgresql/data \ + postgres:latest +``` + +##### MySQL + +```shell +# Start MySQL using Docker +docker run -d --name mysql \ + -p 3306:3306 \ + -e MYSQL_ROOT_PASSWORD=mysql \ + mysql:latest +``` + +Create database: + +```sql +CREATE DATABASE `Platform-V70`; +``` + +##### SQL Server (coming soon) + +```shell +# Start SQL Server using Docker +docker run -d --name sqlserver \ + -p 1433:1433 \ + -e "ACCEPT_EULA=Y" \ + -e "SA_PASSWORD=yourStrong(!)Password" \ + mcr.microsoft.com/mssql/server:latest +``` + +#### 2. Configuration File Modification + +Modify the database connection strings in the following configuration files according to your chosen database: + +- `migrations/LY.MicroService.Applications.Single.DbMigrator/appsettings.json` +- `LY.MicroService.Applications.Single/appsettings.Development.json` + +Database connection string examples: + +PostgreSQL: + +```json +{ + "ConnectionStrings": { + "Default": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;" + } +} +``` + +MySQL: + +```json +{ + "ConnectionStrings": { + "Default": "Server=127.0.0.1;Database=Platform-V70;User Id=root;Password=123456;SslMode=None" + } +} +``` + +SQL Server (coming soon): + +```json +{ + "ConnectionStrings": { + "Default": "Server=localhost,1433;Database=Platform-V70;User Id=sa;Password=yourStrong(!)Password;TrustServerCertificate=True" + } +} +``` + +#### 3. Redis Service + +```shell +# Start Redis using Docker +docker run -d --name redis -p 6379:6379 redis:latest +``` + +Redis configuration example: + +```json +{ + "DistributedLock": { + "IsEnabled": true, + "Redis": { + "Configuration": "127.0.0.1,defaultDatabase=14" + } + }, + "Redis": { + "IsEnabled": true, + "Configuration": "127.0.0.1,defaultDatabase=15", + "InstanceName": "LINGYUN.Abp.Application" + }, + "Features": { + "Validation": { + "Redis": { + "Configuration": "127.0.0.1,defaultDatabase=13", + "InstanceName": "LINGYUN.Abp.Application" + } + } + } +} +``` + +### Optional Configuration + +The following configurations are applicable for monolithic distributed architecture: + +#### 1. MinIO Distributed File Storage + +```json +{ + "Minio": { + "WithSSL": false, + "BucketName": "blobs", + "EndPoint": "127.0.0.1:19000", + "AccessKey": "{AccessKey}", + "SecretKey": "{SecretKey}", + "CreateBucketIfNotExists": false + } +} +``` + +#### 2. Elasticsearch Distributed Audit Logging + +```json +{ + "Elasticsearch": { + "NodeUris": "http://127.0.0.1:9200" + } +} +``` + +## Database Initialization + +1. Run database migration script: + +Option 1 (Recommended): + +```shell +./aspnet-core/migrations/Migrate.ps1 +``` + +Follow the command line prompts to generate migration files and SQL scripts, then execute the SQL scripts to create database tables + +Option 2: +Taking PostgreSQL as an example: + +- Modify database connection information in `LY.MicroService.Applications.Single.DbMigrator/appsettings.PostgreSql.json` +- Navigate to `LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql` project +- Run `dotnet ef database update` +- Wait for migration completion + +2. Configure data initialization: + + - Modify database connection information in `LY.MicroService.Applications.Single.DbMigrator/appsettings.json` + - Ensure the correct database provider is selected + +3. Execute data migration: + - Run the `LY.MicroService.Applications.Single.DbMigrator` project + - Wait for migration to complete, basic table data will be initialized + +## Service Startup + +1. Run the `LY.MicroService.Applications.Single` project +2. Access Swagger API documentation in your browser: + - URL: http://127.0.0.1:30000/swagger + +## Configuration Details + +### 1. Basic Configuration + +#### Application Configuration + +```json +{ + "App": { + "ShowPii": true, + "SelfUrl": "http://127.0.0.1:30001/", + "CorsOrigins": "http://127.0.0.1:3100,http://127.0.0.1:30001" + } +} +``` + +#### Distributed Cache Configuration + +```json +{ + "DistributedCache": { + "HideErrors": true, + "KeyPrefix": "LINGYUN.Abp.Application", + "GlobalCacheEntryOptions": { + "SlidingExpiration": "30:00:00", + "AbsoluteExpirationRelativeToNow": "60:00:00" + } + } +} +``` + +### 2. Authentication Configuration + +#### OpenIddict Configuration + +```json +{ + "OpenIddict": { + "Applications": { + "VueAdmin": { + "ClientId": "vue-admin-client", + "RootUrl": "http://127.0.0.1:3100/" + } + }, + "Lifetime": { + "AccessToken": "14:00:00", + "IdentityToken": "00:20:00", + "RefreshToken": "14:00:00" + } + } +} +``` + +#### Identity Authentication Configuration + +```json +{ + "Identity": { + "Password": { + "RequiredLength": 6, + "RequireNonAlphanumeric": false, + "RequireLowercase": false, + "RequireUppercase": false, + "RequireDigit": false + }, + "Lockout": { + "AllowedForNewUsers": false, + "LockoutDuration": 5, + "MaxFailedAccessAttempts": 5 + }, + "SignIn": { + "RequireConfirmedEmail": false, + "RequireConfirmedPhoneNumber": false + } + } +} +``` + +### 3. Feature Management Configuration + +```json +{ + "FeatureManagement": { + "IsDynamicStoreEnabled": true + }, + "SettingManagement": { + "IsDynamicStoreEnabled": true + }, + "PermissionManagement": { + "IsDynamicStoreEnabled": true + } +} +``` + +### 4. Logging Configuration + +```json +{ + "Serilog": { + "MinimumLevel": { + "Default": "Information", + "Override": { + "System": "Warning", + "Microsoft": "Warning" + } + }, + "WriteTo": [ + { + "Name": "File", + "Args": { + "path": "Logs/Info-.log", + "rollingInterval": "Day" + } + } + ] + } +} +``` + +## Common Issues + +If you encounter problems, please check: + +1. Database connection string is correct +2. Correct database provider is selected +3. Redis connection is working +4. Required ports are not occupied +5. Database migration completed successfully +6. Authentication server configuration is correct +7. CORS configuration is correct (if frontend access has cross-origin issues) diff --git a/docs/startup-aio-readme.md b/docs/startup-aio-readme.md new file mode 100644 index 000000000..3f1feb0c9 --- /dev/null +++ b/docs/startup-aio-readme.md @@ -0,0 +1,348 @@ +# 单体服务启动指南 + +[English](startup-aio-readme.en.md) | 简体中文 + +## 目录 + +- [环境要求](#环境要求) +- [项目编译](#项目编译) +- [环境配置](#环境配置) + - [必选配置](#必选配置) + - [可选配置](#可选配置) +- [数据库初始化](#数据库初始化) +- [服务启动](#服务启动) +- [配置说明](#配置说明) + +## 环境要求 + +- .NET 8.0 SDK +- 数据库(支持以下任一种): + - PostgreSQL + - MySQL + - SQL Server(即将支持) +- Redis +- Docker(可选) + +## 项目编译 + +1. 确保已安装 .NET 8.0 SDK +2. 在项目根目录执行以下命令编译整个项目: + +```shell +./build/build-aspnetcore-release.ps1 +``` + +3. 使用 IDE 打开 `LY.MicroService.Applications.Single` 解决方案进行调试或发布 + +## 环境配置 + +### 必选配置 + +#### 1. 数据库配置 + +支持多种数据库,以下是各种数据库的配置示例: + +##### PostgreSQL + +```shell +# 使用Docker启动PostgreSQL +docker run -d --name postgres \ + -p 5432:5432 \ + -e POSTGRES_PASSWORD=postgres \ + -e PGDATA=/var/lib/postgresql/data \ + postgres:latest +``` + +##### MySQL + +```shell +# 使用Docker启动MySQL +docker run -d --name mysql \ + -p 3306:3306 \ + -e MYSQL_ROOT_PASSWORD=mysql \ + mysql:latest +``` + +创建数据库: + +```sql +CREATE DATABASE `Platform-V70`; +``` + +##### SQL Server(即将支持) + +```shell +# 使用Docker启动SQL Server +docker run -d --name sqlserver \ + -p 1433:1433 \ + -e "ACCEPT_EULA=Y" \ + -e "SA_PASSWORD=yourStrong(!)Password" \ + mcr.microsoft.com/mssql/server:latest +``` + +#### 2. 配置文件修改 + +需要根据选择的数据库类型修改以下配置文件中的数据库连接字符串: + +- `migrations/LY.MicroService.Applications.Single.DbMigrator/appsettings.json` +- `LY.MicroService.Applications.Single/appsettings.Development.json` + +数据库连接字符串示例: + +PostgreSQL: + +```json +{ + "ConnectionStrings": { + "Default": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;" + } +} +``` + +MySQL: + +```json +{ + "ConnectionStrings": { + "Default": "Server=127.0.0.1;Database=Platform-V70;User Id=root;Password=123456;SslMode=None" + } +} +``` + +SQL Server(即将支持): + +```json +{ + "ConnectionStrings": { + "Default": "Server=localhost,1433;Database=Platform-V70;User Id=sa;Password=yourStrong(!)Password;TrustServerCertificate=True" + } +} +``` + +#### 3. Redis 服务 + +```shell +# 使用Docker启动Redis +docker run -d --name redis -p 6379:6379 redis:latest +``` + +Redis 配置示例: + +```json +{ + "DistributedLock": { + "IsEnabled": true, + "Redis": { + "Configuration": "127.0.0.1,defaultDatabase=14" + } + }, + "Redis": { + "IsEnabled": true, + "Configuration": "127.0.0.1,defaultDatabase=15", + "InstanceName": "LINGYUN.Abp.Application" + }, + "Features": { + "Validation": { + "Redis": { + "Configuration": "127.0.0.1,defaultDatabase=13", + "InstanceName": "LINGYUN.Abp.Application" + } + } + } +} +``` + +### 可选配置 + +以下配置适用于单体分布式架构: + +#### 1. MinIO 分布式文件存储 + +```json +{ + "Minio": { + "WithSSL": false, + "BucketName": "blobs", + "EndPoint": "127.0.0.1:19000", + "AccessKey": "{AccessKey}", + "SecretKey": "{SecretKey}", + "CreateBucketIfNotExists": false + } +} +``` + +#### 2. Elasticsearch 分布式审计日志 + +```json +{ + "Elasticsearch": { + "NodeUris": "http://127.0.0.1:9200" + } +} +``` + +## 数据库初始化 + +1. 运行数据库迁移脚本: + +方案一(推荐): + +```shell +./aspnet-core/migrations/Migrate.ps1 +``` + +根据命令行提示生成迁移文件和 sql 脚本,然后执行 sql 脚本来创建数据表 + +方案二: +以 pgsql 为例 + +- 修改 `LY.MicroService.Applications.Single.DbMigrator/appsettings.PostgreSql.json` 中的数据库连接信息 +- 进入`LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql`项目 +- 运行 `dotnet ef database update` +- 等待数据迁移完成 + +2. 配置数据初始化: + + - 修改 `LY.MicroService.Applications.Single.DbMigrator/appsettings.json` 中的数据库连接信息 + - 确保选择了正确的数据库提供程序 + +3. 执行数据迁移: + - 运行 `LY.MicroService.Applications.Single.DbMigrator` 项目 + - 等待数据迁移完成,基础表数据将被初始化 + +## 服务启动 + +1. 运行 `LY.MicroService.Applications.Single` 项目 +2. 在浏览器中访问 Swagger 接口文档: + - URL: http://127.0.0.1:30000/swagger + +## 配置说明 + +### 1. 基础配置 + +#### 应用程序配置 + +```json +{ + "App": { + "ShowPii": true, + "SelfUrl": "http://127.0.0.1:30001/", + "CorsOrigins": "http://127.0.0.1:3100,http://127.0.0.1:30001" + } +} +``` + +#### 分布式缓存配置 + +```json +{ + "DistributedCache": { + "HideErrors": true, + "KeyPrefix": "LINGYUN.Abp.Application", + "GlobalCacheEntryOptions": { + "SlidingExpiration": "30:00:00", + "AbsoluteExpirationRelativeToNow": "60:00:00" + } + } +} +``` + +### 2. 认证配置 + +#### OpenIddict 配置 + +```json +{ + "OpenIddict": { + "Applications": { + "VueAdmin": { + "ClientId": "vue-admin-client", + "RootUrl": "http://127.0.0.1:3100/" + } + }, + "Lifetime": { + "AccessToken": "14:00:00", + "IdentityToken": "00:20:00", + "RefreshToken": "14:00:00" + } + } +} +``` + +#### 身份认证配置 + +```json +{ + "Identity": { + "Password": { + "RequiredLength": 6, + "RequireNonAlphanumeric": false, + "RequireLowercase": false, + "RequireUppercase": false, + "RequireDigit": false + }, + "Lockout": { + "AllowedForNewUsers": false, + "LockoutDuration": 5, + "MaxFailedAccessAttempts": 5 + }, + "SignIn": { + "RequireConfirmedEmail": false, + "RequireConfirmedPhoneNumber": false + } + } +} +``` + +### 3. 功能开关配置 + +```json +{ + "FeatureManagement": { + "IsDynamicStoreEnabled": true + }, + "SettingManagement": { + "IsDynamicStoreEnabled": true + }, + "PermissionManagement": { + "IsDynamicStoreEnabled": true + } +} +``` + +### 4. 日志配置 + +```json +{ + "Serilog": { + "MinimumLevel": { + "Default": "Information", + "Override": { + "System": "Warning", + "Microsoft": "Warning" + } + }, + "WriteTo": [ + { + "Name": "File", + "Args": { + "path": "Logs/Info-.log", + "rollingInterval": "Day" + } + } + ] + } +} +``` + +## 常见问题 + +如果遇到问题,请检查: + +1. 数据库连接字符串是否正确 +2. 是否选择了正确的数据库提供程序 +3. Redis 连接是否正常 +4. 必要的端口是否被占用 +5. 数据库迁移是否成功完成 +6. 认证服务器配置是否正确 +7. CORS 配置是否正确(如果前端访问出现跨域问题)