本文主要是介绍Spring Cloud中Eureka开启密码认证,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
原文链接:http://www.dubby.cn/detail.html?id=9006
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的基本安全配置结束了。
这篇关于Spring Cloud中Eureka开启密码认证的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!