6.搭建Eureka

eureka-server自己也是一个微服务,所以eureka-server在启动的时候也会将自己注册到eureka上。eureka集群的时候,会将多个eureka相互注册,这个时候,defaultZone的值会有多个,用逗号隔开。

java 复制代码
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>cloud-demo</artifactId>
        <groupId>com.xkj.org</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>eureka-server</artifactId>

    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>

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

    </dependencies>
</project>
java 复制代码
server:
  port: 10086
spring:
  application:
    name: eureka-server #eureka服务名称
eureka:
  client:
    service-url:
      defaultZone: http://localhost:10086/eureka #eureka地址信息,
java 复制代码
@SpringBootApplication
@EnableEurekaServer
public class EurekaApplication {

    public static void main(String[] args) {
        SpringApplication.run(EurekaApplication.class, args);
    }
}
相关推荐
王彬泽9 小时前
【微服务】组件、基础工程构建(day2)
微服务
Cikiss9 小时前
微服务实战——SpringCache 整合 Redis
java·redis·后端·微服务
Cikiss9 小时前
微服务实战——平台属性
java·数据库·后端·微服务
攸攸太上13 小时前
JMeter学习
java·后端·学习·jmeter·微服务
妍妍的宝贝14 小时前
k8s 中微服务之 MetailLB 搭配 ingress-nginx 实现七层负载
nginx·微服务·kubernetes
架构师吕师傅16 小时前
性能优化实战(三):缓存为王-面向缓存的设计
后端·微服务·架构
王彬泽18 小时前
【微服务】服务注册与发现、分布式配置管理 - Nacos
微服务·服务注册与发现·分布式配置管理
攸攸太上1 天前
Spring Gateway学习
java·后端·学习·spring·微服务·gateway
一直在进步的派大星1 天前
Docker 从安装到实战
java·运维·docker·微服务·容器
Gogeof2 天前
云原生化 - 基础镜像(简约版)
微服务·云原生·基础镜像