1.简单搭建springboot+springcloud项目
2.首先配置eureka的security,响应pom依赖
<!--配置security-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
3.写入yml配置,因为是eureka,所以我们可以将用户名和密码写死,下面是我的yml文件配置,用户名密码写死成user,123456
server:
port: 9000
eureka:
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://localhost:9000/eureka/
server:
renewalPercentThreshold: 0.49
spring:
application:
name: eureka-server
security:
user:
name: user
password: 123456
4.eureka的security配置完成,启动并输入地址访问时会被拦截至security的登陆界面,输入在配置文件中配置的用户名和密码:user,123456点击登录即可跳转至eureka界面