Skip to content

配置文件(环境变量)

  • 点击 appsettings.json 前面的箭头,可以展开或收起配置文件: appsetting.Development.jsonappsetting.Production.json

appsettings.json

公共的配置文件,用于存放公共的配置信息

appsettings.Production.json

生产环境的配置文件,用于存放生产环境的配置信息, 可以配置生产环境的数据库连接字符串等

appsettings.Development.json

开发环境的配置文件,用于存放开发环境的配置信息, 可以配置开发环境的数据库连接字符串等

数据库配置

json
"MainDB": "MainDB", //当前项目的主库,所对应的连接字符串的Enabled必须为true
"MutiDBEnabled": true, //是否开启多库模式
"CQRSEnabled": true, //是否开启读写分离模式,数据库类型要一致,比如都是SqlServer
"SnowWorkId": 20, // 多节点部署时,每个都要改成不同的值,防止重复, 取值范围 1-30
"DBS": [
  /*
    对应下边的 DBType
    MySql = 0,
    SqlServer = 1,
    Sqlite = 2,
    Oracle = 3,
    PostgreSQL = 4,
    Dm = 5,//达梦
    Kdbndp = 6,//人大金仓
  */
  {
    "ConnId": "MainDB",
    "DBType": 0, // MySql
    "Enabled": true,
    "HitRate": 40,
    "Connection": "server=xxx;port=3306;database=xxx;uid=xxx;pwd=xxx;AllowUserVariables=true;SslMode=none;AllowPublicKeyRetrieval=True;CharSet=UTF8mb4;"
  },
  {
    "ConnId": "readonly_1",
    "DBType": 0,
    "Enabled": false,
    "HitRate": 40,
    "IsReadonlyDb": true, // 配置只读库, 默认false
    "Connection": "server=xxx;port=3306;database=xxx;uid=xxx;pwd=xxx;SslMode=none;AllowPublicKeyRetrieval=True;CharSet=UTF8mb4;"
  },
  {
    "ConnId": "MainDB",
    "DBType": 1, // SqlServer
    "Enabled": false,
    "HitRate": 40,
    "Connection": "Data Source=xxx;Initial Catalog=mtest;User=sa;Password=xxx;MultipleActiveResultSets=True;Encrypt=True;TrustServerCertificate=True;",
    "ProviderName": "System.Data.SqlClient"
  }
]
"MainDB": "MainDB", //当前项目的主库,所对应的连接字符串的Enabled必须为true
"MutiDBEnabled": true, //是否开启多库模式
"CQRSEnabled": true, //是否开启读写分离模式,数据库类型要一致,比如都是SqlServer
"SnowWorkId": 20, // 多节点部署时,每个都要改成不同的值,防止重复, 取值范围 1-30
"DBS": [
  /*
    对应下边的 DBType
    MySql = 0,
    SqlServer = 1,
    Sqlite = 2,
    Oracle = 3,
    PostgreSQL = 4,
    Dm = 5,//达梦
    Kdbndp = 6,//人大金仓
  */
  {
    "ConnId": "MainDB",
    "DBType": 0, // MySql
    "Enabled": true,
    "HitRate": 40,
    "Connection": "server=xxx;port=3306;database=xxx;uid=xxx;pwd=xxx;AllowUserVariables=true;SslMode=none;AllowPublicKeyRetrieval=True;CharSet=UTF8mb4;"
  },
  {
    "ConnId": "readonly_1",
    "DBType": 0,
    "Enabled": false,
    "HitRate": 40,
    "IsReadonlyDb": true, // 配置只读库, 默认false
    "Connection": "server=xxx;port=3306;database=xxx;uid=xxx;pwd=xxx;SslMode=none;AllowPublicKeyRetrieval=True;CharSet=UTF8mb4;"
  },
  {
    "ConnId": "MainDB",
    "DBType": 1, // SqlServer
    "Enabled": false,
    "HitRate": 40,
    "Connection": "Data Source=xxx;Initial Catalog=mtest;User=sa;Password=xxx;MultipleActiveResultSets=True;Encrypt=True;TrustServerCertificate=True;",
    "ProviderName": "System.Data.SqlClient"
  }
]