日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學無先后,達者為師

網站首頁 編程語言 正文

.NET?Core使用Eureka實現服務注冊_實用技巧

作者:AZRNG ? 更新時間: 2022-08-29 編程語言

首先先安裝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
		}
	}
}

原文鏈接:https://www.cnblogs.com/azrng/p/12178468.html

欄目分類
最近更新