资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

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注册中心单机

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


分享文章:1、eureka注册中心单机-创新互联
文章位置:http://cdkjz.cn/article/ejcis.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220