springcloud:eureka集群配置

服务器1:

application.yml配置文件:

 server:
  port: 8777


eureka:
  instance:
    hostname: EurekaServer8777
  client:
    register-with-eureka: false
    fetch-registry: false
    service-url:
      defaultZone: http://EurekaServer8888.com:8888/eureka/

依赖文件:

<?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">
    <parent>
        <artifactId>microservice_cloud_01</artifactId>
        <groupId>com.offcn</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>microservice_cloud_05_privider_eureka01_8777</artifactId>

    <dependencies>
        <!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-netflix-eureka-server -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
            <version>2.1.0.RELEASE</version>
        </dependency>
    </dependencies>

</project>

启动类:

package com.offcn;


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

@SpringBootApplication
@EnableEurekaServer
public class AppStarts {

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

服务器二:

application.yml配置文件:

 server:
  port: 8777


eureka:
  instance:
    hostname: EurekaServer8888
  client:
    register-with-eureka: false
    fetch-registry: false
    service-url: 
      defaultZone: http://EurekaServer8777.com:8777/eureka/

依赖文件:

<?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">
    <parent>
        <artifactId>microservice_cloud_01</artifactId>
        <groupId>com.offcn</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>microservice_cloud_06_privider_eureka01_8888</artifactId>

    <dependencies>
        <!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-netflix-eureka-server -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
            <version>2.1.0.RELEASE</version>
        </dependency>
    </dependencies>

</project>

启动类:

package com.offcn;


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

@SpringBootApplication
@EnableEurekaServer
public class AppStart {

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

posted @ 2019-11-07 23:06  孤独的根号er  阅读(281)  评论(0编辑  收藏  举报