springcloud-Eureka注册中心搭建

  1. 导入相关的pom依赖
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-eureka-server</artifactId>
    <version>1.4.6.RELEASE</version>
</dependency>

 

 

  1. 配置相关的配置文件
server:
  port: 7001
​
eureka:
  instance:
    hostname: localhost
  client:
    #是否注册到注册中心
    register-with-eureka: false
    #表示自己就是注册中心
    fetch-registry: false
    service-url:
      # 配置多个表示集群
      defaultZone: http://localhost:7002/eureka, http://localhost:7003/eureka
​
  server:
    #表示开启eureka的自我保护机制,其实默认就是开启的
    enable-self-preservation: true

 

 

  1. 编写主启动类开启服务
@SpringBootApplication
@EnableEurekaServer
public class EurekaServer_7001 {
    public static void main(String[] args) {
        SpringApplication.run(EurekaServer_7001.class, args);
    }
}

 

 

posted @ 2021-06-25 13:49  紫川先生  阅读(39)  评论(0)    收藏  举报