In this coding exercise for learning microservices, I've created a Netflix Zuul project for service routing my microservices.
Sadly, the /routes endpoint does not seem to be mounted. Everything else seems to be working fine: Defining prefixes and setting up specific routes for my services.
There are no errors on the zuul server log files. When I try to hit the /routes url on postman, I get an 404 error:
My Zuul application class:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
@SpringBootApplication
@EnableZuulProxy
public class ZuulServerApplication {
public static void main(String[] args) {
SpringApplication.run(ZuulServerApplication.class, args);
}
}
pom.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion> <!--should be set to 4.0.0 -->
<groupId>com.booking.system.hotel</groupId>
<version>0.0.1-SNAPSHOT</version>
<artifactId>hotel-gateway-service-server</artifactId>
<name>Hotel Gateway service - zuul</name>
<description>Hotel Gateway service - it uses Netflix Zuul Proxy Server</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.5.RELEASE</version>
</parent>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Finchley.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<start-class>com.booking.system.hotel.zuulsvr.ZuulServerApplication</start-class>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-zuul</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-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-client</artifactId>
</dependency>
</dependencies>
<build>
<finalName>hotel-gateway-service-server</finalName> <!--name of the jar -->
<plugins>
<!-- packages the project as an executable jar, as an Spring Boot application -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- used for running tests at various stages -->
</plugins>
</build>
</project>
bootstrap.yml file:
spring:
application:
name: hotel-gateway-service-server
profiles:
active:
default
cloud:
config:
enabled: true
Zuul configuration file from configuration server:
zuul.ignored-services: "*"
zuul.prefix: /api
zuul.routes.hotel-reservations-service: /reservations/**
zuul.routes.hotel-rooms-service: /rooms/**
docker-compose.yml entry for initializing the zuul gateway server:
hotel-gateway-service-server: #zuul server
image: imageprefix/hotel-gateway-service-server
ports:
- 5555:5555
environment:
PROFILE: "dev"
SERVER_PORT: "5555"
CONFIGSERVER_URI: "http://hotel-configuration-server:8888"
CONFIGSERVER_PORT: "8888"
EUREKASERVER_URI: "http://hotel-service-discovery-server:8761/eureka/"
EUREKASERVER_PORT: "8761"
I don't seem to spot what I am missing.
The actuator base path has changed to /actuator
. So you need to use /actuator/routes
. It is also not enabled by default.
management.endpoints.web.exposure.include=*
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With