java 注册中心_搭建Eureka服务注册中心

搭建Eureka服务注册中心

前面说过eureka是c/s模式的  server服务端就是服务注册中心,其他的都是client客户端,服务端用来管理所有服务,客户端通过注册中心,来调用具体的服务;

我们先来搭建下服务端,也就是服务注册中心;

新建 module   microservice-eureka-server-2001

4.0.0

com.java1234.springcloud

microservice

0.0.1-SNAPSHOT

microservice-eureka-server-2001

org.springframework.cloud

spring-cloud-starter-eureka-server

org.springframework

springloaded

org.springframework.boot

spring-boot-devtools

主要是加入eureka-server依赖;

application.yml配置:server:

port: 2001

context-path: /

eureka:

instance:

hostname: localhost #eureka注册中心实例名称

client:

register-with-eureka: false     #false 由于该应用为注册中心,所以设置为false,代表不向注册中心注册自己。

fetch-registry: false     #false 由于注册中心的职责就是维护服务实例,它并不需要去检索服务,所以也设置为false

service-url:

defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/       #设置与Eureka注册中心交互的地址,查询服务和注册服务用到

启动类:package com.java1234;

import org.springframework.boot.SpringApplication;

import org.springframework.boot.autoconfigure.SpringBootApplication;

import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;

@SpringBootApplication

@EnableEurekaServer

public class EurekaApplication_2001 {

public static void main(String[] args) {

SpringApplication.run(EurekaApplication_2001.class, args);

}

}

主要是要加入下@EnableEurekaServer

测试:

4bda89149f2c0da5bcf94d7508016579.png

出现这个 就说明OK;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值