微服务如何快速搭建eureka注册中心

微服务中如何搭建eureka注册中心目前好多公司都在使用微服务技术,微服务中的注册中心应该是最常用的模块,那么怎么通过eureka快速构建注册中心呢?咱们直接上代码。第一步:前提是maven项目,pom.xml文件是必须的, 通过此文件引入项目中需要的jar包。 <parent> <artifactId>coca-servers</arti...
摘要由CSDN通过智能技术生成

微服务中如何搭建eureka注册中心

目前好多公司都在使用微服务技术,微服务中的注册中心应该是最常用的模块,那么怎么通过eureka快速构建注册中心呢?咱们直接上代码。
第一步:前提是maven项目,pom.xml文件是必须的, 通过此文件引入项目中需要的jar包。

    <parent>
        <artifactId>coca-servers</artifactId>
        <groupId>com.yazhou.zhongguo</groupId>
        <version>1.0.0-SNAPSHOT</version>
    </parent>
    <modelVersion>1.0.0</modelVersion>

    <artifactId>coca-discovery-server</artifactId>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
        </dependency>
    </dependencies>

第二步:程序启动程序 DiscoveryApplication;

@EnableEurekaServer
@SpringBootApplication
public class DiscoveryApplication {
    public static void main(String[] args) {
        SpringApplication.run(DiscoveryApplication.class,args);
    }
}

第三步:配置文件bootstrap.yml 如下:

spring:
  application:
    name: service-discovery
server:
  port: 7002
eureka:
  dashboard:
    path: /ui
  client:
    register-with-eureka: false
    fetch-registry: false
    service-url:
      defaultZone: http://localhost:7002/eureka

到目前为止,如果你没有其他的特殊要求的话,运行启动类,就可以成功搭建一个注册服务中心了。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值