.net5使用Apollo公共配置

在appsettings.json中添加apollo地址

        

"apollo": {
"AppId": "",
"MetaServer": "http://部署apollo地址"
},

 

在Program.cs

public static void Main(string[] args)
{
CreateHostBuilder(args).Run();
}

public static IWebHost CreateHostBuilder(string[] args) =>
Microsoft.AspNetCore.WebHost.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((hostingContext, builder) =>
{
builder
.AddApollo(builder.Build().GetSection("apollo"))
.AddDefault()
.AddNamespace("application");
})
ConfigureLogging(loggingBuilder =>
{
loggingBuilder.AddLog4Net();//需要配置文件
})
.UseStartup<Startup>()
.Build();

 
posted @ 2021-04-14 15:34  ■乐  阅读(356)  评论(0编辑  收藏  举报