一、eureka注册中心配置
引入security包
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
配置跨域
@Component
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable();
super.configure(http);
}
}
修改配置文件
1.声明security账号密码;
2.链接注册中心url,添加响应的账号密码
server:
port: 7001
spring:
# 安全认证 设置账号密码
security:
user:
name: xxx
password: 123
eureka:
instance:
hostname: euk1.com
client:
service-url:
defaultZone: http://${spring.security.user.name}:${spring.security.user.password}@euk1.com:7001/eureka/