当前位置 : 主页 > 网络编程 > ASP >

.NET Core使用Eureka实现服务注册

来源:互联网 收集:自由互联 发布时间:2023-01-17
首先先安装nuget组件: Steeltoe.Discovery.ClientCore 然后在ConfigureServices中进行注入 services.AddDiscoveryClient(Configuration); Configure中引用 app.UseDiscoveryClient(); Appsettings.json中编写 {"Logging": {"IncludeSc

首先先安装nuget组件:

Steeltoe.Discovery.ClientCore

然后在ConfigureServices中进行注入

services.AddDiscoveryClient(Configuration);

Configure中引用

app.UseDiscoveryClient();

Appsettings.json中编写

{
	"Logging": {
		"IncludeScopes": false,
		"LogLevel": {
			"Default": "Warning"
		}
	},
	"spring": {
		"application": {
			"name": "order11111" //注入的名称
		}
	},
	"eureka": {

		"client": {
			"serviceUrl": "http://192.168.130.132:8761/eureka/",
			"shouldRegisterWithEureka": true, //默认值是true
			"shouldFetchRegistry": false, //设置指示客户端不要获取注册表,因为该应用无需发现服务。它只想注册服务
			"validate_certificates": false
		},
		"instance": {
			"hostName": "192.168.130.148", //默认是在运行时自动确认的 不加上这个的话网关找不到服务
			"port": 14802, //设置该服务中注册的端口
			"leaseRenewalIntervalInSeconds": 30,
			"leaseExpirationDurationInSeconds": 90
		}
	}
}

到此这篇关于.NET Core使用Eureka实现服务注册的文章就介绍到这了。希望对大家的学习有所帮助,也希望大家多多支持易盾网络。

上一篇:.NETCore获取配置文件内容
下一篇:没有了
网友评论