部署Apollo
1 docker-compose快速构建
- 在Github下载
Docker-Compose部署
文件
https://github.com/apolloconfig/apollo/tree/master/scripts/docker-quick-start
- 通过Docker-Compose快速搭建Apollo环境
.NET6项目接入Apollo
引入依赖
<PackageReference Include="Com.Ctrip.Framework.Apollo.Configuration" Version="2.5.0" />
在Program.css
类中添加
builder.WebHost.ConfigureAppConfiguration((hostBuilderContext, configurationBuilder) => { configurationBuilder.AddApollo(hostBuilderContext.Configuration.GetSection("apollo")) .AddNamespace("OrderService-Namespace", ConfigFileFormat.Json).AddDefault(); });
修改appsettings.json
{ "apollo": { "AppId": "orderService-Config", "MetaServer": "http://192.168.3.254:8080", "ConfigServer": [ "http://192.168.3.254:8080" ], "Env": "DEV" } }