Unable to start Ocelot because either a ReRoute or GlobalConfiguration


在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()?

問題原因: 容器中缺少相應的服務

解決辦法:

  1. install-package Ocelot.Provider.Consul
  2. ConfigureServices服務注冊中修改為 : services.AddOcelot(Configuration).AddConsul();

正常運行!
如果有幫助,記得點贊~~~~


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2026 CODEPRJ.COM