• 配置Apollo阿波罗.net core 3.1 c#


    直接上代码:


    public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder => { webBuilder .ConfigureAppConfiguration((hostingContext, builder) => { builder .AddApollo(builder.Build().GetSection("apollo")) .AddDefault() .AddNamespace("application"); }) .UseStartup<Startup>();

    {
      "Logging": {
        "LogLevel": {
          "Default": "Information",
          "Microsoft": "Warning",
          "Microsoft.Hosting.Lifetime": "Information"
        }
      },
      "AllowedHosts": "*",
      "apollo": {
        "AppId": "SampleApp", //AppId
        "MetaServer": "http://192.168.136.129:8080", // Eureka地址
        "ConfigServer": [
          "http://192.168.136.129:8080" //// Eureka地址
        ]
      }
    }
    using Microsoft.AspNetCore.Mvc;
    using Microsoft.Extensions.Configuration;
    using System.Collections.Generic;
    
    namespace WebApolloDemo.Controllers
    {
        [Route("api/[controller]")]
        [ApiController]
        public class ValuesController : Controller
        {
    
            private readonly IConfiguration _configuration;
    
            public ValuesController(IConfiguration configuration)
            {
                _configuration = configuration;
            }
    
            // GET api/values
            [HttpGet]
            public ActionResult<IEnumerable<string>> Get()
            {
                var appName = _configuration["timeout"];
                var hjk = _configuration["zcc"];
                return new string[] { "value1", "value2", appName, hjk };
            }
    
    
        }
    }

    ok,这是web的配置。搭建好Apollo后。

     这样就可以了,后期出细节图。

    相信自己,一切皆有可能!
  • 相关阅读:
    鼠标移入图片放大效果
    搜索框
    将下拉菜单放入input框中
    轮播图2
    V-demo item.vue
    v-demo1 List.vue
    v-demo1 add.vue
    v-demo1 app.vue
    3D轮播图
    封装代码
  • 原文地址:https://www.cnblogs.com/zhaocici/p/14719436.html
Copyright © 2020-2023  润新知