idea新建project
File->New->Project,选择Spring Initializr,设置相关信息,next
Eureka Server项目选择Eureka Server
Eureka Client项目选择Eureka Discovery
pom会自动配置相关依赖
eureka配置

Eureka Server配置:

server:
  port: 8761

spring:
  security:
    user:
      name: xxx
      password: yyy
  application:
    name: @[email protected]
  cloud:
    config:
      enabled: false
eureka:
  instance:
    hostname: eureka
    prefer-ip-address: true
  client:
    register-with-eureka: false
    fetch-registry: false
    service-url:
      defaultZone: http://xxx:[email protected]${eureka.instance.hostname}:${server.port}/eureka/
  server:
    eviction-interval-timer-in-ms: 4000
    enable-self-preservation: false
    renewal-percent-threshold: 0.9

enable-self-preservation: false在生产环境改成true(默认为true)
注意:在启动的主类上加注解@EnableEurekaServer

Eureka Client配置:

spring:
  application:
    name: @[email protected]
eureka:
  instance:
    prefer-ip-address: true
  client:
    service-url:
      defaultZone: http://xxx:[email protected]:8761/eureka/

注意:在启动的主类上加注解@EnableDiscoveryClient

相关文章:

  • 2021-07-03
  • 2021-09-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-10
  • 2021-09-04
  • 2022-12-23
  • 2022-12-23
  • 2022-01-12
  • 2021-10-11
相关资源
相似解决方案