栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > .Net

springcloud报错:com.netflix.discovery.shared.transport.TransportException

.Net 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

springcloud报错:com.netflix.discovery.shared.transport.TransportException

1.完整报错信息:
com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server


2.问题分析:
(1)服务端报错:可能时服务端像自己注册了,需要关闭服务端向自己注册

eureka:
 client:
  fetch-registry: false
  register-with-eureka: false
 service-url:
  defaultZone: http://{eureka.instance.hostname}:eureka.instance.hostname:{server.port}/eureka/

这里需要注意一下,配置文件中idea提示会出现default-zone这种形式,也会报错改为defaultZone

(2)客户端报错:三个原因
一个可能是服务端没有跑起来
二可能defaultZone: 配置的URL有问题
三可能是服务端的端口被占用
针对第2种情况,
你需要认真检查一下 defaultZone: 的配置,和服务端的配置是否一直;
或者是Spring2.0以后默认开的安全验证,你需要手动关闭,关闭方法为添加一个配置方法。

 security:
   basic:
     enabled: true
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
// Configure HttpSecurity as needed (e.g. enable http basic).
http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.NEVER);
http.csrf().disable();
//注意:为了可以使用 http://{user}:user:{password}@{host}:host:{port}/eureka/ 这种方式登录,所以必须是httpBasic,
// 如果是form方式,不能使用url格式登录
http.authorizeRequests().anyRequest().authenticated().and().httpBasic();
}}

然后添加对应的@EnableWebSecurity依赖即可

org.springframework.boot
spring-boot-starter-security
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/905237.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号