spring cloud中启动Eureka Server

一、新建工程《spring cloud中启动Eureka Server》

二、工程结构

《spring cloud中启动Eureka Server》

三、修改配置文件

# eureka.client.registerWithEureka :表示是否将自己注册到Eureka Server,默认为true。由于当前这个应用就是Eureka Server,故而设为false
# eureka.client.fetchRegistry :表示是否从Eureka Server获取注册信息,默认为true。因为这是一个单点的Eureka Server,不需要同步其他的Eureka Server节点的数据,故而设为false。
# eureka.client.serviceUrl.defaultZone :设置与Eureka Server交互的地址,查询服务和注册服务都需要依赖这个地址。默认是http://localhost:8761/eureka ;多个地址可使用 , 分隔。
server:
  port: 8761
eureka:
  client:
    register-with-eureka: false
    fetch-registry: false
    service-url:
      defaultZone: http://localhost:8761/eureka // Eureka Server注册服务的地址

四、添加开启Eureka Server注解

package com.chhliu.springcloud.eureka;

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

@SpringBootApplication
@EnableEurekaServer // 注解支持
public class SpringcloudEurekaApplication {

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

五、验证

在浏览器中输入http://localhost:8761/地址,就可以看到Eureka Server的注册页面了

《spring cloud中启动Eureka Server》

通过上面的几个步骤,单机版的Eureka Server就成功的启动了!

    原文作者:Spring Cloud
    原文地址: https://blog.csdn.net/liuchuanhong1/article/details/54666715
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞