美文网首页
第一篇 eureka服务注册与发现

第一篇 eureka服务注册与发现

作者: Kaven不是程序员 | 来源:发表于2017-11-01 18:25 被阅读22次

介绍

这里copy别人的一张图,我们就从这张图介绍eureka。


eureka 工作流程
  • Eureka Server: 服务端,就是我们说的注册中心。
  • Eureka Provider/Consumer: 客户端,服务的提供者和消费者
    服务提供者/消费者向服务注册中心提供自己的服务,将serverId、port、通信等相关信息告知服务中心。
    我们将按照这张图,提供注册中心、服务提供者及服务消费者。

快速构建

1. Eureka Server

  • 生成一个spring boot 项目,pom文件引入:
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-eureka-server</artifactId>
</dependency>
  • 在启动类上开启注解@EnableEurekaServer
@SpringBootApplication
@EnableEurekaServer
public class KavenRegistCenterServerApplication {
    public static void main(String[] args) {
           SpringApplication.run(KavenRegistCenterServerApplication.class, args);
    }
}
  • application.properties
    主要配置信息,包括应用名、端口(默认8080)、服务注册等
server:
  port: 1001
spring:
  application:
    name: kaven-regist-center-server
#1.5.X版本之后,严格执行安全校验    
management:
  security:
    enabled: false
eureka:
  instance:
    hostname: localhost
  client:
    register-with-eureka: false
    fetch-registry: false

到此一个简单的注册中心就搭建完成。

相关文章

网友评论

      本文标题:第一篇 eureka服务注册与发现

      本文链接:https://www.haomeiwen.com/subject/txmgpxtx.html