http://www.daohangren.cn
第一步:在eureka server中引入依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
第二步:在eureka server配置文件中加入配置
security:
basic:
enabled: true
user:
name: name
password: password
第三步:在client端修改defaultZone地址
eureka:
instance:
instanceId: service
client:
# 表示是否注册自身到eureka服务器
register-with-eureka: false
# 是否从eureka上获取注册信息
fetch-registry: false
serviceUrl:
defaultZone: http://${security.user.name}:${security.user.password}@${server.address}:${server.port}/eurek