在ASP.Net Core項目APIGateway中添加Ocelot+Consul然后運行時 ,VS2017報如下錯 :
內部異常 1: Exception: Unable to start Ocelot, errors are: Unable to start Ocelot, errors are: Unable to start Ocelot because either a ReRoute or GlobalConfiguration are using ServiceDiscoveryOptions but no ServiceDiscoveryFinderDelegate has been registered in dependency injection container. Are you missing a package like Ocelot.Provider.Consul and services.AddConsul() or Ocelot.Provider.Eureka and services.AddEureka()?,Unable to start Ocelot, errors are: Unable to start Ocelot because either a ReRoute or GlobalConfiguration are using ServiceDiscoveryOptions but no ServiceDiscoveryFinderDelegate has been registered in dependency injection container. Are you missing a package like Ocelot.Provider.Consul and services.AddConsul() or Ocelot.Provider.Eureka and services.AddEureka()?
問題原因: 容器中缺少相應的服務
解決辦法:
- install-package Ocelot.Provider.Consul
- ConfigureServices服務注冊中修改為 : services.AddOcelot(Configuration).AddConsul();
正常運行!
如果有幫助,記得點贊~~~~
