ConfigServer的security

1、ConfigServer和EurekaServer的身份验证基本一致

(1)添加依赖

<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-security</artifactId>
</dependency>

(2)添加配置

spring:
    security:
        user:
          name: user
          password: password

name默认是user,password如果不填,会随机一个字符串在控制台

(3)访问

访问首页的时候,就会显示登录页面,要求我们登录

 

注:配置这块,一定要是spring.security.user.name不是security.user.name,之前的版本不知道,但是最起码Finchley这个版本是

posted @ 2019-01-17 14:32  柚子味儿的西瓜  阅读(11)  评论(0)    收藏  举报