问题描述

@Feignclient(value=“xx”)不报错
@Feignclient(value=“xx”, fallback=“xx”)
报错

Caused by: java.lang.ClassNotFoundException: feign.hystrix.FallbackFactory$Default
	at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[na:1.8.0_301]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:418) ~[na:1.8.0_301]
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355) ~[na:1.8.0_301]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[na:1.8.0_301]
	... 76 common frames omitted

所用版本

alibaba2.2.7.RELEASE
cloud2021.0.0
boot2.6.7
<dependencyManagement>
		<dependencies>
			<!--SpringCloudAlibaba-->
			<dependency>
				<groupId>com.alibaba.cloud</groupId>
				<artifactId>spring-cloud-alibaba-dependencies</artifactId>
				<version>2.2.7.RELEASE</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
			<!--SpringCloud-->
			<dependency>
				<groupId>org.springframework.cloud</groupId>
				<artifactId>spring-cloud-dependencies</artifactId>
				<version>2021.0.0</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
			<!--SpringBoot-->
			<dependency>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-dependencies</artifactId>
				<version>2.6.7</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
		</dependencies>
	</dependencyManagement>

问题根因

依赖缺失feign-hytrix下的hytrix-core
在这里插入图片描述

解决方案

加一套依赖

		<dependency>
			<groupId>io.github.openfeign</groupId>
			<artifactId>feign-hystrix</artifactId>
		</dependency>
GitHub 加速计划 / sentine / Sentinel
22.25 K
7.98 K
下载
alibaba/Sentinel: Sentinel 是阿里巴巴开源的一款面向分布式服务架构的流量控制、熔断降级组件,提供实时监控、限流、降级和系统保护功能,适用于微服务治理场景。
最近提交(Master分支:3 个月前 )
195150bc * fix issue 2485 which occur oom when using async servlet request. * optimize imports * 1. fix the same issue in the webmvc-v6x 2. improve based on review comments 2 个月前
b78b09d3 2 个月前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐