我正在尝试创建一个具有断路器设计模式的 api 网关,当请求到达 api 网关微服务时,它会将请求重定向到特定的微服务,而当该微服务关闭时,它将执行回退方法。
运行云网关微服务时收到以下错误消息
java.lang.IllegalArgumentException:找不到类 [org.springframework.boot.actuate.autoconfigure.health.HealthIndicatorAutoConfiguration]
我的配置类在下面
public class GatewayConfiguration {
@Bean
public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
return builder.routes()
.route("order-route",
predicateSpec -> predicateSpec.path("/order/api/orders/")
.filters(filter ->
filter.circuitBreaker(config -> config.setName("order-```circuit-breaker")
```.setFallbackUri("forward:/orderfallback"))
)
.uri("lb://order-service/"))
.build();
}
@Bean
public Customizer<Resilience4JCircuitBreakerFactory> customizer(){
return factory->factory.configureDefault(id-> new Resilience4JConfigBuilder(id)
.circuitBreakerConfig(CircuitBreakerConfig.ofDefaults())
.timeLimiterConfig(TimeLimiterConfig.custom()
.timeoutDuration(Duration
.ofSeconds(2))
.build())
.build());
}
}
My Pom File is below
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.github.resilience4j</groupId>
<artifactId>resilience4j-spring-boot2</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-circuitbreaker-resilience4j</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>