Spring Cloud中Eureka开启密码认证
yqxbc 发布时间:09-20 来源:一起学编程 浏览:9次

Eureka服务端就是服务注册中心,而服务提供者、服务消费者对Eureka来说都是客户端。

Eureka服务端配置

添加spring-boot-starter-security

更改POM文件:

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

设置用户名密码

更改application.properties:

security.user.password=dubby
security.user.name=dubby

重启,打开http://localhost:1111/,如果需要你输入密码,说明安全模块生效了,输入你设置的用户名和密码,可以进入就可以了。

这里写图片描述

Eureka客户端配置

更改application.properties:

eureka.client.serviceUrl.defaultZone=http://dubby:dubby@localhost:1111/eureka/

注意格式是

eureka.client.serviceUrl.defaultZone=http://${userName}:${password}@localhost:1111/eureka/

至此,Eureka的基本安全配置结束了。

如果你有好的win10资讯或者win10教程,以及win10相关的问题想要获得win10系统下载的关注与报道。
欢迎加入发送邮件到657025171#qq.com(#替换为@)。期待你的好消息!