客户端注册Cannot execute request on any known server解决
2024-09-01 00:59:11
在对eureka注册中心服务端添加安全验证后,新版本springcloud出现一个问题就是,在客户端注册到服务中心时报了一个错:Cannot execute request on any known server,重新仔细看了一下官方文档Securing The Eureka Server部分得以解决。
添加安全验证:https://www.cnblogs.com/zrk3/p/springcloud_securing_eurekaserver.html
一、官方文档
大意(英语不好,见谅):
只需通过Spring -boot-starter- security将Spring Security添加到服务路径中,就可以保护Eureka服务。默认情况下,当Spring Security位于类路径上时,它将要求在每次向应用程序发送请求时都发送一个有效的CSRF令牌。Eureka客户机通常不会拥有一个有效的跨站点请求伪造令牌(CSRF),您需要禁用/ Eureka /**端点的这个请求
2、添加配置文件
在eureka服务工程中添加配置文件:
package com.zrk.config; import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; /**
* @Description:
* @Author: zrk
* @Date: 2019/9/12
*/
@EnableWebSecurity
class WebSecurityConfig extends WebSecurityConfigurerAdapter { @Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().ignoringAntMatchers("/eureka/**");
super.configure(http);
}
}
重启eureka服务,重启客户端就发现已经可以注册成功。
最新文章
- spring访问静态资源出错,No mapping found for HTTP request with URI xxx/resources/js/jquery.min.js...
- Xcode7中,如何新建category分类
- 温习SQL server
- HDU5441 Travel 并查集
- 书评<;<;剑指offer 名企面试官精讲典型编程题>;>;
- allegro使用汇总 [转贴]
- dede 5.7进后台卡死解决办法
- 【现代程序设计】【homework-07】
- 你晓得吗?大多数企业根本没有做到 DevOps!
- hadoop进不去web界面
- easyUI自带的时间插件日期选择、月份选择、时间选择的使用(转)
- RabbitMQ 消息队列 入门 第一章
- PHP算法学习(6) 单向链表 实现栈
- Plugin with id &#39;com.novoda.bintray-release&#39; not found.的解决方案
- js中去掉字符串的空格、回车换行
- Unicode String to a UTF-8 TypedArray Buffer in JavaScript
- Nios II——定制自己的IP1之Nios接口类型
- 停止一个java的线程执行
- 深入理解Linux内核-系统调用
- 学霸网站之NABC
热门文章
- js回调函数(callback)(转载)
- Python接口测试-利用登录后的session用到登录后的接口中
- 性能测试 | 系统运行缓慢,CPU 100%,Full GC次数过多问题排查
- 安装win10提示“我们无法创建新的分区,也找不到现有分区”
- 怎么用php实现短信验证码发送
- CentOS 7 最小化安装后的注意事项
- [Kaggle] How to kaggle?
- Linux学习—maven安装
- Asp.net Core深入一:数据库访问(Mysql为例)
- LeetCode.1185-一周中的星期几(Day of the Week)