• SpringCloud之注册中心Eureka搭建


    POM:

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.2.RELEASE</version>
    </parent>
    
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Camden.SR6</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
    
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka-server</artifactId>
        </dependency>
    </dependencies>

    application.properties

    spring.application.name=eureka-server
    
    server.port=10001
    
    #强制不注册到注册服务器
    eureka.client.register-with-eureka=false
    eureka.client.fetch-registry=false
    
    #注册中心地址
    eureka.client.serviceUrl.defaultZone=http://localhost:${server.port}/eureka/
    
    #驱逐下线的服务,间隔,5秒,默认是60,建议开发和测试环境配置
    #org.springframework.cloud.netflix.eureka.server.EurekaServerConfigBean.evictionIntervalTimerInMs
    eureka.server.evictionIntervalTimerInMs=5000

    启动类:

    package com.yzl.cloud.eureka;
    
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.boot.builder.SpringApplicationBuilder;
    import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
    
    @SpringBootApplication
    @EnableEurekaServer
    public class EurekaApplication {
    
        public static void main(String[] args) {
            new SpringApplicationBuilder(EurekaApplication.class).web(true).run(args);
            
            //或者pom引spring-boot-starter-web,然后用下面这个启动
            //SpringApplication.run(EurekaApplication.class, args);
        }
    
    }

    启动服务:spring-boot:run或者直接运行启动类

    访问:http://localhost:10001/   能看到控制台

  • 相关阅读:
    读书笔记:HTML5的Doctype
    2017/09/06~2017/09/10:算法练习小记
    (分治)7617:输出前k大的数
    (递归)7215:简单的整数划分问题
    (递归)2106:Boolean Expressions
    (递归)8758:2的幂次方表示
    (递归)1750:全排列
    (枚举)8469:特殊密码锁
    关于使用unigui、webxone、mysql的几个问题
    DELPHI-Delphi常用类型及定义单元
  • 原文地址:https://www.cnblogs.com/yangzhilong/p/6734841.html
Copyright © 2020-2023  润新知