Spring Cloud(2)A Eureka server端 服务注册建立
1. 父项目pom
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Greenwich.RELEASE</version>
<type>pom</type>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.1.3.RELEASE</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
2.Eureka pom
<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency> <dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
<version>2.1.0.RELEASE</version>
</dependency> <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
3. yml 配置
server:
port: 7001 eureka:
instance:
hostname: localhost #eureka服务器的实例名称
client:
register-with-eureka: false #表示不想注册中心注册自己
fetch-registry: false #表示自己就是注册中心
service-url:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/ #设置与eureka server交互的地址查询服务
客户端向服务端每30s 发送一次心跳,90s 之后客户端如果没有发送心跳,Service 会去除这个客户端
4.启动类
package com.service; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; @SpringBootApplication
@EnableEurekaServer //服务器启动类,接受其他微服务注册进来
public class Dept_Eureka { public static void main(String[] args){
SpringApplication.run(Dept_Eureka.class,args);
}
}
Spring Cloud(2)A Eureka server端 服务注册建立的更多相关文章
- Spring Cloud Eureka 2 (Eureka Server搭建服务注册中心)
工具:IntelliJ IDEA 2017.1.2 x64.maven3.3.9 打开IDE file===>new===>project next next 选择相应的依赖 next ...
- spring cloud 学习(2) - eureka server注册中心高可用及安全认证
接上节继续,注册中心单点肯定是不牢靠的,可以参考下面的方案做成注册中心集群: 弄成3个节点,每个节点向其它节点注册,这样只要集群中有一个节点正常工作即可.为了方便在本机弄出这种效果,我们先修改下hos ...
- Spring Cloud系列(一):服务注册中心
一.Spring Cloud简介 Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智能路由,微代理,控制总线).分布式系统的协调导致了样 ...
- <Spring Cloud>入门一 Eureka Server
1.搭建父工程 主要是添加版本依赖,此处版本是: spring-boot : 2.0.8.RELEASE spring-cloud : Finchley.SR2 <?xml version=& ...
- Spring Cloud环境搭建: Eureka Server
项目目录结构, 总共三个文件 ├── pom.xml └── src ├── main │ ├── java │ │ └── com │ │ └── rockbb │ │ ...
- Spring Cloud Alibaba 初体验(二) Nacos 服务注册与发现 + 集成 Spring Cloud Gateway
一.服务注册 添加依赖: <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>s ...
- Spring Cloud进阶之路 | 一:服务注册与发现(nacos)
转载请注明作者及出处: 作者:银河架构师 原文链接:https://www.cnblogs.com/luas/p/12068846.html 1.版本 最新稳定版本为1.1.4,也可以从发版说明.博客 ...
- Spring Cloud Eureka Server高可用注册服务中心的配置
前言 Eureka 作为一个云端负载均衡,本身是一个基于REST的服务,在 Spring Cloud 中用于发现和注册服务. 那么当成千上万个微服务注册到Eureka Server中的时候,Eurek ...
- Spring Cloud(二):Spring Cloud Eureka Server高可用注册服务中心的配置
前言 Eureka 作为一个云端负载均衡,本身是一个基于REST的服务,在 Spring Cloud 中用于发现和注册服务. 那么当成千上万个微服务注册到Eureka Server中的时候,Eurek ...
随机推荐
- 如何查看java对象的大小
有时需要查看java对象占用了多少内存(对象大小),lucene为我们提供了一个很好的工具类,操作简单,如下: int[] s = new int[1024]; System.out.println( ...
- 单元素枚举类型singleton模块
public enum Elvis { INSTANCE; public void leaveTheBuilding() { System.out.println("Whoa baby, I ...
- redis(Springboot中封装整合redis,java程序如何操作redis的5种基本数据类型)
平常测试redis操作命令,可能用的是cmd窗口 操作redis,记录一下 java程序操作reids, 操作redis的方法 可以用Jedis ,在springboot 提供了两种 方法操作 Red ...
- redis实现对账(集合比较)功能
现状:每日在进行系统之间的订单对账时,往往是这样的操作流程: 1.从外部系统拉取数据存入本地数据库: 2.查询本地订单数据集合localSet: 3.查询外部系统订单数据集合outerSet; 4.以 ...
- R语言—使用函数sample进行抽样
在医学统计学或者流行病学里的现场调查.样本选择经常会提到一个词:随机抽样.随机抽样是为了保证各比较组之间均衡性的一个很重要的方法.那么今天介绍的第一个函数就是用于抽样的函数sample: > ...
- [UE4]AWP狙击枪开镜
一.使用一张PNG图片,中间是透明的,其他部分是纯黑色.创建一个UserWidget.作为AWP的开镜后的准心.AWP默认状态下是没有准心的. 二.右键开镜.把第一步创建的UserWidget创建出来 ...
- [UE4]枚举Enum和Switch Enum
- [UE4]需要保存的数据
数据存储原则是“相关的放在一起,不相关的分开”. 如果存档有几十上百兆,如果放在一起存储容易出现问题(特别是网络游戏):断线.电脑死机.游戏出错等等,存档就会损坏,所以一定要分割存储.
- 为什么QQ空间和QQ邮箱都是IE默认打开?
为什么QQ空间和QQ邮箱都是IE默认打开? 我已经设置成chrome为默认浏览器了 原文转载至:https://zhidao.baidu.com/question/390662851068217285 ...
- 禅道-bug管理系统部署
官方下载: https://www.zentao.net/framework/zentao11.2-80109.html 官方使用说明:(含安装及使用说明,很详细) https://www.zenta ...