Spring 启动 2.3.1 和 Spring 云网关 2.2.1 ;无法找到名为 Custom FilterName 的 GatewayFilterFactory
Spring boot 2.3.1 and Spring cloud gatewat 2.2.1 ; Unable to find GatewayFilterFactory with name CustomFilterName
我创建了一个名为“CustomFilterName”的自定义过滤器,下面是我的配置和 java 个文件。
收到错误:
reactor.core.Exceptions$ErrorCallbackNotImplemented:
java.lang.IllegalArgumentException: Unable to find
GatewayFilterFactory with name CustomFilterName Caused by:
java.lang.IllegalArgumentException: Unable to find
GatewayFilterFactory with name CustomFilterName
at
org.springframework.cloud.gateway.route.RouteDefinitionRouteLocator.loadGatewayFilters(RouteDefinitionRouteLocator.java:180)
~[spring-cloud-gateway-core-2.2.0.RELEASE.jar:2.2.0.RELEASE] at
org.springframework.cloud.gateway.route.RouteDefinitionRouteLocator.getFilters(RouteDefinitionRouteLocator.java:226)
~[spring-cloud-gateway-core-2.2.0.RELEASE.jar:2.2.0.RELEASE] at
org.springframework.cloud.gateway.route.RouteDefinitionRouteLocator.convertToRoute(RouteDefinitionRouteLocator.java:163)
~[spring-cloud-gateway-core-2.2.0.RELEASE.jar:2.2.0.RELEASE] at
reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:100)
~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at
reactor.core.publisher.FluxFlatMap$FlatMapMain.drainLoop(FluxFlatMap.java:704)
~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at
reactor.core.publisher.FluxFlatMap$FlatMapMain.drain(FluxFlatMap.java:580)
~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at
reactor.core.publisher.FluxFlatMap$FlatMapInner.onSubscribe(FluxFlatMap.java:970)
~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at
reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:161)
~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at
reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:86)
~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at
reactor.core.publisher.Flux.subscribe(Flux.java:8325)
~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at
reactor.core.publisher.FluxFlatMap$FlatMapMain.onNext(FluxFlatMap.java:418)
~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at
reactor.core.publisher.FluxIterable$IterableSubscription.slowPath(FluxIterable.java:267)
~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at
reactor.core.publisher.FluxIterable$IterableSubscription.request(FluxIterable.java:225)
~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at
reactor.core.publisher.FluxFlatMap$FlatMapMain.onSubscribe(FluxFlatMap.java:363)
~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at
reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:161)
~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at
reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:86)
~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at
reactor.core.publisher.Flux.subscribe(Flux.java:8325)
~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at
reactor.core.publisher.FluxFlatMap$FlatMapMain.onNext(FluxFlatMap.java:418)
~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at
reactor.core.publisher.FluxIterable$IterableSubscription.slowPath(FluxIterable.java:267)
~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at
reactor.core.publisher.FluxIterable$IterableSubscription.request(FluxIterable.java:225)
~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at
reactor.core.publisher.FluxFlatMap$FlatMapMain.onSubscribe(FluxFlatMap.java:363)
~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at
reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:161)
~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at
reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:86)
~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at
reactor.core.publisher.InternalFluxOperator.subscribe(InternalFluxOperator.java:62)
~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at
reactor.core.publisher.FluxDefer.subscribe(FluxDefer.java:54)
~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at
reactor.core.publisher.Flux.subscribe(Flux.java:8325)
~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at
reactor.core.publisher.Flux.subscribeWith(Flux.java:8494)
~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at
reactor.core.publisher.Flux.subscribe(Flux.java:8295)
~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at
reactor.core.publisher.Flux.subscribe(Flux.java:8222)
~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at
reactor.core.publisher.Flux.subscribe(Flux.java:8140)
~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at
org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter.lambda$onApplicationEvent[=15=](WeightCalculatorWebFilter.java:145)
~[spring-cloud-gateway-core-2.2.0.RELEASE.jar:2.2.0.RELEASE] at
org.springframework.beans.factory.ObjectProvider.ifAvailable(ObjectProvider.java:93)
~[spring-beans-5.2.7.RELEASE.jar:5.2.7.RELEASE] at
org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter.onApplicationEvent(WeightCalculatorWebFilter.java:145)
~[spring-cloud-gateway-core-2.2.0.RELEASE.jar:2.2.0.RELEASE] at
org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE] at
org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE] at
org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE] at
org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:404)
~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE] at
org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:361)
~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE] at
org.springframework.cloud.gateway.route.RouteRefreshListener.reset(RouteRefreshListener.java:68)
~[spring-cloud-gateway-core-2.2.0.RELEASE.jar:2.2.0.RELEASE] at
org.springframework.cloud.gateway.route.RouteRefreshListener.onApplicationEvent(RouteRefreshListener.java:49)
~[spring-cloud-gateway-core-2.2.0.RELEASE.jar:2.2.0.RELEASE] at
org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE] at
org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE] at
org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE] at
org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:404)
~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE] at
org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:361)
~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE] at
org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:898)
~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE] at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:554)
~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE] at
org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:62)
~[spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE] at
org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758)
[spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE] at
org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750)
[spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE] at
org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
[spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE] at
org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
[spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE] at
org.springframework.boot.SpringApplication.run(SpringApplication.java:1237)
[spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE] at
org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
[spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
CustomFilterName.java
@Component
public class CustomFilterName extends AbstractGatewayFilterFactory<CustomFilterName.Config> {
final Logger logger = LoggerFactory.getLogger(CustomFilterName.class);
public static final String A_var = "thisIsA_Class";
public static final String B_var = "thisIsB_Class";
public CustomFilterName() {
super(Config.class);
}
@Override
public GatewayFilter apply(Config config) {
return new OrderedGatewayFilter((exchange, chain) -> {
logger.info("Pre GatewayFilter logging: " + config.getA_var());
return chain.filter(exchange).then(Mono.fromRunnable(() -> {
logger.info("Post GatewayFilter logging: " + config.getB_var());
}));
}, 1);
}
public static class Config {
private String A_var;
private String B_var;
public String getA_var() {
return A_var;
}
public void setA_var(String a_var) {
A_var = a_var;
}
public String getB_var() {
return B_var;
}
public void setB_var(String b_var) {
B_var = b_var;
}
public Config() {
};
public Config(String A_var, String B_var) {
super();
this.A_var = A_var;
this.B_var = B_var;
}
}
}
app.yml
spring:
application:
name: gs-gateway
cloud:
gateway:
routes:
- id: test_route
uri: http://httpbin.org/
predicates:
- Path=/incoming/**
filters:
- AddRequestHeader=X-Y-Host, delta
- name: CustomFilterName
args:
A_var: thisIsA_yml
B_var: thisIsB_yml
pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.1.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<spring-cloud.version>Hoxton.RELEASE</spring-cloud.version>
<spring-cloud-gateway.version>2.2.1.RELEASE</spring-cloud-gateway.version>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
<version>${spring-cloud-gateway.version}</version>
</dependency>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
是的,我必须通过删除 repo 文件夹中的所有旧依赖项来清理我的 M2 repo 文件夹。并进行了全新的 Maven Force 更新。上面提到的错误消失了。
我创建了一个名为“CustomFilterName”的自定义过滤器,下面是我的配置和 java 个文件。
收到错误:
reactor.core.Exceptions$ErrorCallbackNotImplemented: java.lang.IllegalArgumentException: Unable to find GatewayFilterFactory with name CustomFilterName Caused by: java.lang.IllegalArgumentException: Unable to find GatewayFilterFactory with name CustomFilterName
at org.springframework.cloud.gateway.route.RouteDefinitionRouteLocator.loadGatewayFilters(RouteDefinitionRouteLocator.java:180) ~[spring-cloud-gateway-core-2.2.0.RELEASE.jar:2.2.0.RELEASE] at org.springframework.cloud.gateway.route.RouteDefinitionRouteLocator.getFilters(RouteDefinitionRouteLocator.java:226) ~[spring-cloud-gateway-core-2.2.0.RELEASE.jar:2.2.0.RELEASE] at org.springframework.cloud.gateway.route.RouteDefinitionRouteLocator.convertToRoute(RouteDefinitionRouteLocator.java:163) ~[spring-cloud-gateway-core-2.2.0.RELEASE.jar:2.2.0.RELEASE] at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:100) ~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at reactor.core.publisher.FluxFlatMap$FlatMapMain.drainLoop(FluxFlatMap.java:704) ~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at reactor.core.publisher.FluxFlatMap$FlatMapMain.drain(FluxFlatMap.java:580) ~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at reactor.core.publisher.FluxFlatMap$FlatMapInner.onSubscribe(FluxFlatMap.java:970) ~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:161) ~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:86) ~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at reactor.core.publisher.Flux.subscribe(Flux.java:8325) ~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at reactor.core.publisher.FluxFlatMap$FlatMapMain.onNext(FluxFlatMap.java:418) ~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at reactor.core.publisher.FluxIterable$IterableSubscription.slowPath(FluxIterable.java:267) ~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at reactor.core.publisher.FluxIterable$IterableSubscription.request(FluxIterable.java:225) ~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at reactor.core.publisher.FluxFlatMap$FlatMapMain.onSubscribe(FluxFlatMap.java:363) ~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:161) ~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:86) ~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at reactor.core.publisher.Flux.subscribe(Flux.java:8325) ~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at reactor.core.publisher.FluxFlatMap$FlatMapMain.onNext(FluxFlatMap.java:418) ~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at reactor.core.publisher.FluxIterable$IterableSubscription.slowPath(FluxIterable.java:267) ~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at reactor.core.publisher.FluxIterable$IterableSubscription.request(FluxIterable.java:225) ~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at reactor.core.publisher.FluxFlatMap$FlatMapMain.onSubscribe(FluxFlatMap.java:363) ~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:161) ~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:86) ~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at reactor.core.publisher.InternalFluxOperator.subscribe(InternalFluxOperator.java:62) ~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at reactor.core.publisher.FluxDefer.subscribe(FluxDefer.java:54) ~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at reactor.core.publisher.Flux.subscribe(Flux.java:8325) ~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at reactor.core.publisher.Flux.subscribeWith(Flux.java:8494) ~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at reactor.core.publisher.Flux.subscribe(Flux.java:8295) ~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at reactor.core.publisher.Flux.subscribe(Flux.java:8222) ~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at reactor.core.publisher.Flux.subscribe(Flux.java:8140) ~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE] at org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter.lambda$onApplicationEvent[=15=](WeightCalculatorWebFilter.java:145) ~[spring-cloud-gateway-core-2.2.0.RELEASE.jar:2.2.0.RELEASE] at org.springframework.beans.factory.ObjectProvider.ifAvailable(ObjectProvider.java:93) ~[spring-beans-5.2.7.RELEASE.jar:5.2.7.RELEASE] at org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter.onApplicationEvent(WeightCalculatorWebFilter.java:145) ~[spring-cloud-gateway-core-2.2.0.RELEASE.jar:2.2.0.RELEASE] at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE] at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE] at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE] at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:404) ~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE] at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:361) ~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE] at org.springframework.cloud.gateway.route.RouteRefreshListener.reset(RouteRefreshListener.java:68) ~[spring-cloud-gateway-core-2.2.0.RELEASE.jar:2.2.0.RELEASE] at org.springframework.cloud.gateway.route.RouteRefreshListener.onApplicationEvent(RouteRefreshListener.java:49) ~[spring-cloud-gateway-core-2.2.0.RELEASE.jar:2.2.0.RELEASE] at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE] at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE] at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE] at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:404) ~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE] at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:361) ~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:898) ~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:554) ~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE] at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:62) ~[spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) [spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) [spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) [spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
CustomFilterName.java
@Component
public class CustomFilterName extends AbstractGatewayFilterFactory<CustomFilterName.Config> {
final Logger logger = LoggerFactory.getLogger(CustomFilterName.class);
public static final String A_var = "thisIsA_Class";
public static final String B_var = "thisIsB_Class";
public CustomFilterName() {
super(Config.class);
}
@Override
public GatewayFilter apply(Config config) {
return new OrderedGatewayFilter((exchange, chain) -> {
logger.info("Pre GatewayFilter logging: " + config.getA_var());
return chain.filter(exchange).then(Mono.fromRunnable(() -> {
logger.info("Post GatewayFilter logging: " + config.getB_var());
}));
}, 1);
}
public static class Config {
private String A_var;
private String B_var;
public String getA_var() {
return A_var;
}
public void setA_var(String a_var) {
A_var = a_var;
}
public String getB_var() {
return B_var;
}
public void setB_var(String b_var) {
B_var = b_var;
}
public Config() {
};
public Config(String A_var, String B_var) {
super();
this.A_var = A_var;
this.B_var = B_var;
}
}
}
app.yml
spring:
application:
name: gs-gateway
cloud:
gateway:
routes:
- id: test_route
uri: http://httpbin.org/
predicates:
- Path=/incoming/**
filters:
- AddRequestHeader=X-Y-Host, delta
- name: CustomFilterName
args:
A_var: thisIsA_yml
B_var: thisIsB_yml
pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.1.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<spring-cloud.version>Hoxton.RELEASE</spring-cloud.version>
<spring-cloud-gateway.version>2.2.1.RELEASE</spring-cloud-gateway.version>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
<version>${spring-cloud-gateway.version}</version>
</dependency>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
是的,我必须通过删除 repo 文件夹中的所有旧依赖项来清理我的 M2 repo 文件夹。并进行了全新的 Maven Force 更新。上面提到的错误消失了。