标签:.class coding cloud 1.0 desc toc www name gre
单实例Eureka Server配置<?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 http://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>2.1.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.zws.cloud</groupId>
<artifactId>Eurka-Server1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Eurka-Server1</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Greenwich.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<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-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
server:
port: 8761
eureka:
instance:
hostname: localhost
client:
# 下面两行表明自己是一个EurekaServer服务
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
spring:
application:
name: Eureka-Server
package com.zws.cloud.server;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@EnableEurekaServer
@SpringBootApplication
public class EurekaServerApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaServerApplication.class, args);
}
}
http://localhost:8761/
集群配置只在配置文件上有区别
1.Server1
server:
port: 8761
eureka:
instance:
hostname: peer1
client:
# 下面两行表明自己是一个EurekaServer服务
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://peer2:8762/eureka/,http://peer3:8763/eureka/
spring:
application:
name: Eureka-Server1
2.Server2
server:
port: 8762
eureka:
instance:
hostname: peer2
client:
# 下面两行表明自己是一个EurekaServer服务
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://peer1:8761/eureka/,http://peer3:8763/eureka/
spring:
application:
name: Eureka-Server2
3.Server3
server:
port: 8763
eureka:
instance:
hostname: peer3
client:
# 下面两行表明自己是一个EurekaServer服务
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://peer1:8761/eureka/,http://peer2:8762/eureka/
spring:
application:
name: Eureka-Server3
4./etc/hosts配置
127.0.0.1 peer1
127.0.0.1 peer2
127.0.0.1 peer3
标签:.class coding cloud 1.0 desc toc www name gre
原文地址:http://blog.51cto.com/wenshengzhu/2350971