老生常谈的配置 但是还是需要说明一下
EurekaApplication
@EnableEurekaServer指定为server端
?
|
1
2
3
4
5
6
7
8
9
|
@EnableEurekaServer
@SpringBootApplication
public class EurekaApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaApplication.class, args);
}
}
|
WebSecurityConfig
看到这眼熟不呢 没错 Eureka也开启spring security 在访问前台页面时也需要输入账号密码
?
|
1
2
3
4
5
6
7
8
9
10
|
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
super.configure(http);
http.csrf().disable().httpBasic();
}
}
|
application.yml
security:user以下配置的账号密码 在访问页面需要输入的
?
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
server:
port: 7001
spring:
application:
name: eureka
security:
user:
name: admin
password: xxxxxxxxxx
eureka:
client:
fetch-registry: false
register-with-eureka: false
service-url:
defaultZone: http://admin:Xk38CNHigBP5jK75@localhost:5001/eureka
instance:
hostname: localhost
prefer-ip-address: true
logging:
config: classpath:logback.xml
level:
root: info
|
pom.xml
?
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
|
当访问localhost:7001 出现下图 需要填写账号密码
在其他服务注册时 也需要指定账号密码
?
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
eureka:
instance:
hostname: ${spring.cloud.client.ip-address}
prefer-ip-address: true
instance-id: ${eureka.instance.hostname}:${server.port}
//与server一致
client:
security:
basic:
user: admin
password: xxxxxxxxxxx
service-url:
defaultZone: http://${eureka.client.security.basic.user}:${eureka.client.security.basic.password}@localhost:7001/eureka
|
到此这篇关于spring cloud ouath2中的Eureka的文章就介绍到这了,更多相关spring cloud ouath2内容请搜索快网idc以前的文章或继续浏览下面的相关文章希望大家以后多多支持快网idc!
原文链接:https://blog.csdn.net/qq_20143059/article/details/113759124
相关文章
猜你喜欢
- ASP.NET本地开发时常见的配置错误及解决方法? 2025-06-10
- ASP.NET自助建站系统的数据库备份与恢复操作指南 2025-06-10
- 个人网站服务器域名解析设置指南:从购买到绑定全流程 2025-06-10
- 个人网站搭建:如何挑选具有弹性扩展能力的服务器? 2025-06-10
- 个人服务器网站搭建:如何选择适合自己的建站程序或框架? 2025-06-10
TA的动态
- 2025-07-10 怎样使用阿里云的安全工具进行服务器漏洞扫描和修复?
- 2025-07-10 怎样使用命令行工具优化Linux云服务器的Ping性能?
- 2025-07-10 怎样使用Xshell连接华为云服务器,实现高效远程管理?
- 2025-07-10 怎样利用云服务器D盘搭建稳定、高效的网站托管环境?
- 2025-07-10 怎样使用阿里云的安全组功能来增强服务器防火墙的安全性?
快网idc优惠网
QQ交流群
您的支持,是我们最大的动力!
热门文章
-
2025-05-27 90
-
2025-06-05 62
-
2025-05-29 33
-
2025-05-25 81
-
2025-05-29 95
热门评论


