Eureka服务端配置

1、pom.xml

注意:

Finchley版本的SpringCloud对于Eureka的依赖配置为

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

Camden版本的依赖是

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

2、application.yml

spring:
  application:
    name: eureka-server
server:
  port: 8761
eureka:
  instance:
    #eureka服务端配置
    prefer-ip-address: false
#   不使用主机名来定义注册中心的地址,而使用IP地址的形式
    status-page-url-path: /actuator/info
    # 获取此实例状态页的URL路径,然后构造出主机名,安全端口等,默认为/info
    health-check-url-path: /actuator/health
    # 获取此实例的相对健康检查URL路径,默认为/health
  client:
    #eureka客户端配置
    register-with-eureka: true
      #   实例是否在eureka服务器上注册自己的信息以供其他服务发现,默认为true
    fetch-registry: false
      #     此客户端是否获取eureka服务器注册表上的注册信息,默认为true
    service-url:
        #    指定服务注册中心的地址
      defaultZone: http://localhost:8761/eureka/

3、在SpringBoot的启动类上面加上EurekaServer的注解

@SpringBootApplication
@EnableEurekaServer
public class EurekaServerApplication {

    public static void main(String[] args) {
        SpringApplication.run(EurekaServerApplication.class, args);
    }
}

4、启动后访问

5、Eureka的配置

可以参考下面链接很是全面

https://www.cnblogs.com/fangfuhai/p/7070325.html

猜你喜欢

转载自blog.csdn.net/weixin_42152604/article/details/84568532