自定义一个抽象类,实现 GatewayFilter, Ordered
import org.springframework.cloud.gateway.filter.GatewayFilter;
import org.springframework.core.Ordered;
/**
* @author 向振华
* @date 2022/02/08 14:11
*/
public abstract class GatewayFilterOrdered implements GatewayFilter, Ordered {
}
然后GatewayFilterFactory那里return new GatewayFilterOrdered(),其中getOrder中的值就可以自定义执行顺序了。
import org.springframework.cloud.gateway.filter.GatewayFilter;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.factory.AbstractNameValueGatewayFilterFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
/**
* @author 向振华
* @date 2022/02/08 13:47
*/
@Component
public class FaGatewayFilterFactory extends AbstractNameValueGatewayFilterFactory {