@EnableZuulProxy switched on Netflix Zuul 1 as an API gateway in a Spring Cloud application, routing incoming requests to backend services. It is obsolete: Spring Cloud Netflix Zuul was removed from the Spring Cloud release train starting with the 2020.0 release, and the replacement is Spring Cloud Gateway.
If you maintain an older project you may still meet the annotation. This article explains what it did and shows how to move the same routes to Spring Cloud Gateway.
The annotation came from the spring-cloud-starter-netflix-zuul module. It turned the application into a reverse proxy and was a superset of @EnableZuulServer, adding features that depended on other Netflix components:
Zuul 1 is built on the blocking servlet model: each request occupies a thread for its full duration. Netflix moved to the asynchronous Zuul 2, but Spring Cloud never integrated it. Zuul 1 went into maintenance mode, and Ribbon and Hystrix followed. Spring Cloud removed these projects in the 2020.0 release train, so @EnableZuulProxy is unavailable on any currently supported Spring Boot version.
Spring Cloud Gateway runs on Spring WebFlux and Netty, so it is non-blocking. Its core concepts are:
| Concept | Role |
|---|---|
| Route | An id, a destination URI, predicates and filters |
| Predicate | A condition on the request, such as a path or header match |
| Filter | Code that changes the request or response, for example stripping a prefix |
There is no enabling annotation. Adding the gateway starter to a Spring Boot application is enough. The starter's artifact name depends on the release train (for example spring-cloud-starter-gateway in older trains and a WebFlux-specific name in the newest), so check the Spring Cloud Gateway reference for your version. Routes defined in Java work the same way across versions:
The lb://order-service scheme resolves the service name through Spring Cloud LoadBalancer, which replaced Ribbon, using a discovery client such as Eureka. A plain https:// URI proxies to a fixed address.
spring-cloud-starter-netflix-zuul and @EnableZuulProxy.zuul.routes entry into a route with a path predicate.GatewayFilter or GlobalFilter implementations. They run in a reactive chain, so avoid blocking calls.It is more than deprecated: Spring Cloud Netflix Zuul is not part of the 2020.0 and later release trains. Only legacy applications pinned to old versions still use it.
Spring Cloud Gateway. It offers routing, filters, load balancing and circuit breaking on a non-blocking foundation.
Spring Cloud LoadBalancer replaces Ribbon, and Spring Cloud CircuitBreaker with Resilience4j replaces Hystrix.
Only if you want service-name based routing with lb://. Gateway also works with fixed URIs or other discovery systems.
@EnableZuulProxy enabled Netflix Zuul 1 as a blocking API gateway with Eureka, Ribbon and Hystrix support, and it no longer exists in current Spring Cloud. Migrate to Spring Cloud Gateway by defining routes with predicates and filters, using Spring Cloud LoadBalancer and CircuitBreaker in place of Ribbon and Hystrix.