• springcloud eureka注册中心搭建


    环境描述

    ① jdk1.8

    ② idea

    ③ springcloud版本 Finchley.SR2

    ④ maven3.0+

    导入jar包

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
      </properties>
    
      <parent>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-parent</artifactId>
          <version>2.0.2.RELEASE</version>
      </parent>
    
      <dependencyManagement>
          <dependencies>
             <dependency>
                 <groupId>org.springframework.cloud</groupId>
                 <artifactId>spring-cloud-dependencies</artifactId>
                 <version>Finchley.SR2</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>
      </dependencies>
    
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>                                   
                    <fork>true</fork>
                    <addResources>true</addResources>
                </configuration>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>

    添加配置application.yml

    server:
      port: 8761
    spring:
      application:
        name: smart-platform-eureka1
    eureka:
      instance:
        hostname: localhost
      client:
        registerWithEureka: false
        fetchRegistry: false
        serviceUrl:
          defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
      server:
        #eureka服务自我保护模式 默认是开启的
        enable-self-preservation: false
        #eureka服务 指定时间清理死掉的服务 默认60秒 单位毫秒
        eviction-interval-timer-in-ms: 60000

    编写eureka服务启动类

    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.boot.builder.SpringApplicationBuilder;
    import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
    
    @SpringBootApplication
    @EnableEurekaServer
    public class Application {
        public static void main( String[] args) throws Exception{
            new SpringApplicationBuilder(Application.class).run(args);
        }
    }

    效果展示红色提示语是因为application.yml配置中将服务自我保护模式设置为了false

  • 相关阅读:
    PAT甲级1060 Are They Equal【模拟】
    PAT甲级1131 Subway Map【dfs】【输出方案】
    PAT甲级1052 Linked List Sorting
    Dev的GridControl控件选择框的使用
    关于MongoDB数据库中文件唯一性的问题
    docker-学习笔记5-存储卷
    docker-学习笔记4-网络
    docker-学习笔记3-镜像基础
    docker-学习笔记2-基础用法
    docker-学习笔记1-基础入门
  • 原文地址:https://www.cnblogs.com/gyli20170901/p/10030374.html
Copyright © 2020-2023  润新知