spring-cloud-netflix eureka服务添加基本用户验证

来自于stackoverflow问题的整理

只需要在工程中依赖 org.springframework.boot:spring-boot-starter-security

在bootstrap.yml中添加以下配置即可

security:
  basic:
    enabled: true
  user:
    name: ctp_config
    password: ctp_config


更为详细的描述

在Eureka server中放置如下配置

security:
  basic:
    enabled: true
  user:
      name: user # login username
      password: password

在服务配置中增加一下配置

eureka:
  client:
    registerWithEureka: true
    fetchRegistry: true
    serviceUrl:
      defaultZone: http://user:password@localhost:8761/eureka/



你可能感兴趣的:(微服务)