网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

1、eureka注册中心单机

公众号:java乐园
源码: https://gitee.com/hjj520/spring-cloud-2.x

网站建设哪家好,找创新互联建站!专注于网页设计、网站建设、微信开发、重庆小程序开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了方正免费建站欢迎大家使用!

一、简介
Spring Cloud Eureka是Spring Cloud Netflix项目下的服务治理模块。而Spring Cloud Netflix项目是Spring Cloud的子项目之一,主要内容是对Netflix公司一系列开源产品的包装,它为Spring Boot应用提供了自配置的Netflix OSS整合。通过一些简单的注解,开发者就可以快速的在应用中配置一下常用模块并构建庞大的分布式系统。它主要提供的模块包括:服务发现(Eureka),断路器(Hystrix),智能路由(Zuul),客户端负载均衡(Ribbon)等。
1、 新建一个maven项目:sc-eureka-server,其pom.xml配置如下:


    4.0.0

    spring-cloud
    sc-eureka-server
    0.0.1-SNAPSHOT
    jar

    sc-eureka-server
    http://maven.apache.org

    
        org.springframework.boot
        spring-boot-starter-parent
        2.0.4.RELEASE
    

    
        
            
                org.springframework.cloud
                spring-cloud-dependencies
                Finchley.RELEASE
                pom
            

        
    

    
        UTF-8
        1.8
        1.8
    

    
        
        
                org.springframework.cloud
                spring-cloud-starter-netflix-eureka-server
                2.0.1.RELEASE
        

    

备注:
主要引入eureka server所需的starter

    
            org.springframework.cloud
            spring-cloud-starter-netflix-eureka-server
        

Spring Cloud 1.x之前的eureka server的starter为


        org.springframework.cloud
        spring-cloud-starter-eureka-server
        1.4.5.RELEASE

在http://mvnrepository.com中央仓库spring-cloud-starter-eureka-server已经被标志为过期,推荐使用spring-cloud-starter-netflix-eureka-server
1、eureka注册中心单机
2、 添加配置文件bootstrap.yml或者application.yml

spring:
    application:
        name: sc-eureka-server

server:
    port: 5001

eureka:
    instance:
        hostname: 127.0.0.1
    client:
        #由于该应用为注册中心,所以设置为false,代表不向注册中心注册自己
        registerWithEureka: false
        #由于注册中心的职责就是维护服务实例,它并不需要去检索服务,所以也设置为false
        frechRegistry: false
        serviceUrl:
            defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/

备注:也可以使用application-dev.yml配置文件,但是添加如下配置:-Dspring.profiles.active=dev
1、eureka注册中心单机

3、 编写启动程序

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

@SpringBootApplication
@EnableEurekaServer
public class EurekaServerApplication {

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

}

4、 启动程序,并验证启动成功
方式一:
1、eureka注册中心单机
方式二:

1、eureka注册中心单机


当前名称:1、eureka注册中心单机
分享网址:http://bjjierui.cn/article/pgopgs.html

其他资讯