Eureka服务端就是服务注册中心,而服务提供者、服务消费者对Eureka来说都是客户端。
更改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/,如果需要你输入密码,说明安全模块生效了,输入你设置的用户名和密码,可以进入就可以了。
更改application.properties:
eureka.client.serviceUrl.defaultZone=http://dubby:dubby@localhost:1111/eureka/
注意格式是
eureka.client.serviceUrl.defaultZone=http://${userName}:${password}@localhost:1111/eureka/
至此,Eureka的基本安全配置结束了。