Eureka 笔记

这篇具有很好参考价值的文章主要介绍了Eureka 笔记。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

服务端:

创建springBoot 项目

1.步骤 导入在pom.xml中         导入        eureka-server的 jar包

2.步骤 在主方法加注解        @EnableEurekaServer

3. 步骤 在配置config

1.步骤pox.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>3.1.3</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>

  <!-- Generated by https://start.springboot.io -->
  <!-- 优质的 spring/boot/data/security/cloud 框架中文文档尽在 => https://springdoc.cn -->
	<groupId>com.csdn</groupId>
	<artifactId>springboot-ms-eureka-server</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>war</packaging>
	<name>springboot-ms-eureka-server</name>
	<description>eureka服务端</description>
	<properties>
		<java.version>17</java.version>
		<spring-cloud.version>2022.0.4</spring-cloud.version>
	</properties>
	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>
		<!-- eureka 1.步骤-->
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-tomcat</artifactId>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
	</dependencies>
	<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>org.springframework.cloud</groupId>
				<artifactId>spring-cloud-dependencies</artifactId>
				<version>${spring-cloud.version}</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
		</dependencies>
	</dependencyManagement>

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
		</plugins>
	</build>

</project>

2.步骤 :加注解@EnableEurekaServer

package com.csdn;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;


@SpringBootApplication
@EnableEurekaServer //2步骤 加注解@EnableEurekaServer
public class MainApplication {

	public static void main(String[] args) {
		SpringApplication.run(MainApplication .class, args);
	}

}

3. 步骤 : resources/application.properties 进行配置

# 3. 步骤config 配置
#eureka服务端应用的端口默认是8761
server.port=9000
#表示是否将自己注册到Eureka Server,默认为true,由于当前应用就是Eureka Server,故而设为false
eureka.client.register-with-eureka=false
# 表示是否从Eureka Server获取注册信息,默认为true,因为这是一个单点的Eureka Server,不需要同步其他的Eureka Server节点的数据,故而设为false
eureka.client.fetch-registry=false
#暴露给其他eureka client客户端 的注册地址
eureka.client.service-url.defaultZone: http://localhost:9000/eureka/

客户端:

1.步骤 导入在pom.xml中         导入        eureka-client的 jar包

 <!-- 1.步骤eureka jar 包-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>

2. 步骤 : resources/application.properties 进行配置

# 3. 步骤config 配置
server.port=8001
#注册到eureka服务端的微服务名称
spring.application.name=ms-consumer-user
#注册到eureka服务端的地址
eureka.client.service-url.defaultZone=http://localhost:9000/eureka/
#点击具体的微服务,右下角是否显示ip
eureka.instance.prefer-ip-address=true
#显示微服务的名称
eureka.instance.instance-id=ms-consumer-user-8001

URL访问地址:http://localhost:9000/

Eureka 笔记,SpringBoot,eureka文章来源地址https://www.toymoban.com/news/detail-704383.html

Operation HTTP action Description
Register new application instance POST /eureka/v2/apps/appID Input: JSON/XMLpayload HTTP Code: 204 on success
De-register application instance DELETE /eureka/v2/apps/appID/instanceID HTTP Code: 200 on success
Send application instance heartbeat PUT /eureka/v2/apps/appID/instanceID HTTP Code:
* 200 on success
* 404 if instanceIDdoesn’t exist
Query for all instances GET /eureka/v2/apps HTTP Code: 200 on success Output: JSON/XML
Query for all appIDinstances GET /eureka/v2/apps/appID HTTP Code: 200 on success Output: JSON/XML
Query for a specific appID/instanceID GET /eureka/v2/apps/appID/instanceID HTTP Code: 200 on success Output: JSON/XML
Query for a specific instanceID GET /eureka/v2/instances/instanceID HTTP Code: 200 on success Output: JSON/XML
Take instance out of service PUT /eureka/v2/apps/appID/instanceID/status?value=OUT_OF_SERVICE HTTP Code:
* 200 on success
* 500 on failure
Move instance back into service (remove override) DELETE /eureka/v2/apps/appID/instanceID/status?value=UP (The value=UP is optional, it is used as a suggestion for the fallback status due to removal of the override) HTTP Code:
* 200 on success
* 500 on failure
Update metadata PUT /eureka/v2/apps/appID/instanceID/metadata?key=value HTTP Code:
* 200 on success
* 500 on failure
Query for all instances under a particular vip address GET /eureka/v2/vips/vipAddress
* HTTP Code: 200 on success Output: JSON/XML 
* 404 if the vipAddress does not exist.
Query for all instances under a particular secure vip address GET /eureka/v2/svips/svipAddress
* HTTP Code: 200 on success Output: JSON/XML 
* 404 if the svipAddress does not exist.

到了这里,关于Eureka 笔记的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • Eureka 笔记

    创建springBoot 项目 1.步骤 导入在pom.xml中         导入        eureka-server的 jar包 2.步骤 在主方法加注解        @EnableEurekaServer 3. 步骤 在配置config 1.步骤pox.xml: 2.步骤 :加注解@EnableEurekaServer 3. 步骤 : resources/application.properties 进行配置 1.步骤 导入在pom.xml中      

    2024年02月09日
    浏览(19)
  • Eureka 学习笔记3:EurekaHttpClient

    版本 awsVersion = ‘1.11.277’ EurekaTransport 用于客户端和服务端之间进行通信,封装了以下接口的实现: ClosableResolver 接口实现 TransportClientFactory 接口实现 EurekaHttpClient 接口实现及其对应的 EurekaHttpClientFactory 接口实现 EurekaHttpClientFactory 是 上层工厂接口 (A top level factory interface)

    2024年02月15日
    浏览(24)
  • Springboot搭建微服务案例之Eureka注册中心

    放一些pojo类 (1)整合mybatis dao层 创建 dao 接口的映射文件还有 mybatis 的核心配置文件 配置 MyBatis 的类型别名,简化 MyBatis 映射文件中的配置  (2)Service 使用 RestTemplate 这个 Java 客户端组件来实现服务的远程调用。所以我们需要将 RestTemplate 使用 Java 配置类进行注入: 这里

    2024年02月05日
    浏览(35)
  • SpringBoot-Eureka-xstream-rce漏洞复现

    actuator 是 springboot 提供的用来对应用系统进行自省和监控的功能模块。其提供的执行器端点分为两类:原生端点和用户自定义扩展端点,原生端点主要有: 漏洞利用 1.利用trace,获取认证信息(Cookie、tooken、Session),利用认证信息访问接口 访问/trace端点获取基本的 HTTP 请求

    2024年01月20日
    浏览(28)
  • Springcloud笔记(2)-Eureka服务注册中心

    Eureka作为一个微服务的治理中心,它是一个服务应用,可以接收其他服务的注册,也可以发现和治理服务实例。 服务治理中心是微服务(分布式)架构中最基础和最核心的功能组件,它主要对各个服务实例进行管理,包括 服务注册和服务发现 等 本文参考:springcloud教程 --

    2024年02月05日
    浏览(32)
  • Eureka 学习笔记6:服务端实例缓存

    版本 awsVersion = ‘1.11.277’ 缓存 类型 registry ConcurrentHashMapString, MapString, LeaseInstanceInfo AbstractInstanceRegistry成员变量 readWriteCacheMap LoadingCache ResponseCacheImpl成员变量 readOnlyCacheMap ConcurrentMapKey, Value ResponseCacheImpl成员变量 registry evictionIntervalTimerInMs 指定清理未续约服务实例的时间间隔

    2024年02月12日
    浏览(24)
  • Eureka 学习笔记1:服务端实例缓存

    版本 awsVersion = ‘1.11.277’ 缓存 类型 registry ConcurrentHashMapString, MapString, LeaseInstanceInfo AbstractInstanceRegistry成员变量 readWriteCacheMap LoadingCache ResponseCacheImpl成员变量 readOnlyCacheMap ConcurrentMapKey, Value ResponseCacheImpl成员变量 registry evictionIntervalTimerInMs 指定清理未续约服务实例的时间间隔

    2024年02月15日
    浏览(32)
  • springboot整合eureka、config搭建注册中心和配置中心

    这篇文章详细介绍怎么通过eureka和config分别搭建一个注册中心和配置中心的服务。 目录 一 、springboot整合eureka搭建注册中心 二、springboot整合config搭建配置中心 三、从配置中心拉取配置 1、在IntelliJ IDEA中创建一个springboot项目,并命名为eureka 2、修改pom.xml,添加eureka-server的依

    2024年02月16日
    浏览(33)
  • Eureka 学习笔记2:客户端 DiscoveryClient

    版本 awsVersion = ‘1.11.277’ DiscoveryClient # cacheRefreshTask shouldFetchRegistry 指定是否从服务端拉取注册列表,默认 true client.refresh.interval 指定从服务端拉取注册列表的时间间隔,默认 30s client.cacheRefresh.exponentialBackOffBound 指定从服务端拉取注册列表的 最大时间间隔 ,默认 10 注1 :当

    2024年02月15日
    浏览(29)
  • SpringCloud学习笔记-Eureka的服务拉取

    假设是OrderService里面拉取Eureka的服务之一User Service 通过服务名称获取IP地址的原理如下图所示,其中由于WIndows电脑的设置,原来的IP地址被替换成为了电脑名称LAPTOPXXX,其实还是可以获取到具体的IP

    2024年02月07日
    浏览(30)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包