springcloud---三节点 eureka server(01)

官网地址
https://cloud.spring.io/spring-cloud-static/Finchley.SR2/multi/multi_spring-cloud-eureka-server.html

1.pom文件引入netflix-eureka-server

<parent>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-parent</artifactId>
	<version>2.0.0.RELEASE</version>
	<relativePath /> <!-- lookup parent from repository -->
</parent>

<properties>
	<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
	<java.version>1.8</java.version>
</properties>

<dependencyManagement>
	<dependencies>
		<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-dependencies -->
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-dependencies</artifactId>
			<version>Finchley.RELEASE</version>
			<type>pom</type>
			<scope>import</scope>
		</dependency>
	</dependencies>
</dependencyManagement>

<dependency>
	<groupId>org.springframework.cloud</groupId>
	<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>

2.SpringCloudEurekaApplication上加注解

@EnableEurekaServer

3.配置主机hostsC:\Windows\System32\drivers\etc\hosts

127.0.0.1 peer1
127.0.0.1 peer2
127.0.0.1 peer3

4.yml配置

spring:
  application:
    name: spring-cloud-eureka
eureka:
  client:
    serviceUrl:
      defaultZone: http://peer1:8000/eureka/,http://peer2:8001/eureka/,http://peer3:8002/eureka/
---
spring:
  profiles: peer1
server:
  port: 8000
eureka:
  instance:
    hostname: peer1
---
spring:
  profiles: peer2
server:
  port: 8001
eureka:
  instance:
    hostname: peer2
---
spring:
  profiles: peer3
server:
  port: 8002
eureka:
  instance:
    hostname: peer3

5.访问

peer1:8000

peer2:8001

peer3:8002
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值