Spring Cloud Config - Cannot clone or checkout repository - java

I am new using Spring Cloud Config.
I have this configuration:
Config
application.yml
server:
port: ${PORT:8888}
spring:
application:
name: config-server
cloud:
config:
server:
git:
uri: https://github.com/username/SpringCloudConfig
username: username
password: password
timeout: 4
security:
basic:
enabled: false
management:
security:
enabled: false
POM.xml
<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>config-server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>config-server</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Dalston.SR1</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<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>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Class
#EnableConfigServer
#SpringBootApplication
public class ConfigServerApplication {
public static void main(String[] args) {
SpringApplication.run(ConfigServerApplication.class, args);
}
}
When I start the server at: http://localhost:8888/health
{"status":"DOWN","diskSpace":{"status":"UP","total":494099492864,"free":440483053568,"threshold":10485760},"refreshScope":{"status":"UP"},"configServer":{"status":"DOWN","repository":{"application":"app","profiles":"default"},"error":"java.lang.IllegalStateException:
Cannot clone or checkout repository"}}
And i i try to start a Service it shows:
2018-08-08 13:43:38.270 INFO 32492 --- [ main]
c.c.c.ConfigServicePropertySourceLocator : Fetching config from server
at: http://localhost:8888 2018-08-08 13:43:42.884 WARN 32492 --- [
main] c.c.c.ConfigServicePropertySourceLocator : Could not locate
PropertySource:
{"timestamp":1533728622334,"status":500,"error":"Internal Server
Error","exception":"java.lang.IllegalStateException","message":"Cannot
clone or checkout repository"path":"/producer-service/default"}"
Service Config
bootstrap.yml
spring:
application:
name: producer-service
Class
#SpringBootApplication
public class ProducerServiceApplication {
public static void main(String[] args) {
SpringApplication.run(ProducerServiceApplication.class, args);
}
}
#RestController
class Producer {
#Value("${message}")
private String message;
#Value("${global-message}")
private String globalMessage;
#RequestMapping(method = RequestMethod.GET)
public Map<String, String> message() {
Map<String, String> response = new HashMap<>();
response.put("message", message);
response.put("global-message", globalMessage);
return response;
}
}

Related

Refresh Scope without config Server

i want to refresh bean when database is updated in runtime, so want to use /refresh endpoint to manually trigger it and refresh bean with new value.
but currently we are not using config server - can anyone guide how i can only make use of refresh scope
I just want to make use of refresh scope without needing config server.
My bean get value from the database for example
#Configuration
public class AppConfiguration {
#Autowired
MyRepository myRepo;
#Bean
#RefreshScope
DemoWebClient getDemoWebClient() {
String currentTime = new Date().getTime() + "";
return new DemoWebClient(myRepo.getTenantId());
}
}
tried to use spring cloud starter
but it is trying to connect config server
2022-01-16 13:25:10.733 INFO 17884 --- [-144.54.177.213] c.c.c.ConfigServicePropertySourceLocator : Connect Timeout Exception on Url - http://localhost:8888. Will be trying the next url if available
2022-01-16 13:25:10.733 WARN 17884 --- [-144.54.177.213] c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: I/O error on GET request for "http://localhost:8888/application/default": Connection refused: connect; nested exception is java.net.ConnectException: Connection refused: connect
2022-01-16 13:25:13.836 INFO 17884 --- [extShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
tried to disable config server lookup - didn't work
spring.cloud.config.enabled=false
spring.cloud.config.import-check.enabled=false
below is my pom
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.8.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>RefreshScopeDemoApp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>RefreshScopeDemoApp</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
<spring-cloud.version>Hoxton.SR8</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<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>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
</repository>
</repositories>
</project>
You need to have the actuator enabled on your application. Then you can just call the endpoint /actuator/refresh of your application, to refresh the beans that need to be refreshed.
The important thing you must understand is that, the actuator must be enabled on the client application of the config server, meaning the application that connects to the config server and not the actual config server.

localhost connection refused in springboot

I am new to springboot. I have a controller class like below,
package com.example.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
#RestController
public class Controller {
#RequestMapping("/hello")
public String getHi() {
return "Hi";
}
}
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>16</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Console,
Starting service [Tomcat]
Starting Servlet engine: [Apache Tomcat/9.0.46]
Initializing Spring embedded WebApplicationContextRoot WebApplicationContext: initialization completed in 626 ms
Tomcat started on port(s): 8080 (http) with context path ''
After running the project I tried opening "localhost:8080/hello" in a browser but I'm getting localhost connection refused. In console, I can able to see that, Tomcat server is started with port 8080.
Thanks in Advance.
UPDATE
I resolved my issue by adding below line in my Main class,
#Autowired
Controller controller;
Try accessing 127.0.0.1:8080/hello to ensure that the loopback is valid

Error starting up Eureka Client with Spring Boot 2.4.1

I am developing an application using Spring Boot 2.4.1 and Eureka. I achieved to start up the Eureka Server, but with the Eureka Client I am getting the following error:
Caused by: java.lang.ClassNotFoundException: com.sun.jersey.client.apache4.ApacheHttpClient4
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:606) ~[na:na]
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:168) ~[na:na]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ~[na:na]
... 55 common frames omitted
...
Caused by: java.lang.NullPointerException: Cannot invoke "org.springframework.cloud.netflix.eureka.CloudEurekaClient.getApplications()" because the return value of "org.springframework.cloud.netflix.eureka.serviceregistry.EurekaRegistration.getEurekaClient()" is null
at org.springframework.cloud.netflix.eureka.serviceregistry.EurekaServiceRegistry.maybeInitializeClient(EurekaServiceRegistry.java:54) ~[spring-cloud-netflix-eureka-client-3.0.0.jar:3.0.0]
at org.springframework.cloud.netflix.eureka.serviceregistry.EurekaServiceRegistry.register(EurekaServiceRegistry.java:38) ~[spring-cloud-netflix-eureka-client-3.0.0.jar:3.0.0]
at org.springframework.cloud.netflix.eureka.serviceregistry.EurekaAutoServiceRegistration.start(EurekaAutoServiceRegistration.java:83) ~[spring-cloud-netflix-eureka-client-3.0.0.jar:3.0.0]
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178) ~[spring-context-5.3.2.jar:5.3.2]
The pom.xml is the following:
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<java.version>15</java.version>
<spring-cloud.version>2020.0.0</spring-cloud.version>
</properties>
<groupId>some.group</groupId>
<artifactId>some-artefact</artifactId>
<version>1.0</version>
<name>some-name</name>
<description>some-description</description>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
</dependencies>
<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>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
The following is the application.yml:
spring:
application:
name: #project.artifactId#
logging:
file.name: ../logs/#project.artifactId#.log
file.max-size: 10MB
server:
port: 8080
And the main class:
#SpringBootApplication
#ComponentScan("com.something")
#EnableDiscoveryClient
public class SpigaConnectorServiceApplication {
public static void main(String[] args) {
SpringApplication.run(SpigaConnectorServiceApplication.class, args);
}
#RestController
class ServiceInstanceRestController {
#Autowired
private DiscoveryClient discoveryClient;
#RequestMapping("/service-instances/{applicationName}")
public List<ServiceInstance> serviceInstancesByApplicationName(
#PathVariable String applicationName) {
return this.discoveryClient.getInstances(applicationName);
}
}
}
The following is the server pom:
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.7.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<java.version>15</java.version>
<spring-cloud.version>Hoxton.SR1</spring-cloud.version>
</properties>
<groupId>com.ptesa.cloud</groupId>
<artifactId>pt-eureka-server</artifactId>
<version>1.0</version>
<name>pt-eureka-server</name>
<description>Registry and discovery of services</description>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
</dependencies>
<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>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
The application.yml of the server:
server:
port: 8761
eureka:
client:
registerWithEureka: false
fetchRegistry: false
And the class that start the server:
#EnableEurekaServer
#SpringBootApplication
public class EurekaServerApplication {
public static void main(String[] args) {
SpringApplication.run(com.ptesa.cloud.EurekaServerApplication.class);
}
}
When using Spring Boot version 2.3.7.RELEASE I don't have this problem. The application starts almost normally. Just get the following warning:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.thoughtworks.xstream.core.util.Fields (file:/C:/Users/Jucaalpa/.m2/repository/com/thoughtworks/xstream/xstream/1.4.11.1/xstream-1.4.11.1.jar) to field java.util.TreeMap.comparator
WARNING: Please consider reporting this to the maintainers of com.thoughtworks.xstream.core.util.Fields
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Is there a way to run Eureka Client with Spring Boot 2.4.1. Do you think it's better to use Spring Boot 2.3.7 because of compatibilities issue like the one I am having?
Thanks you.
I found that adding the following dependency, the problem doesn't occur.
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-apache-client4</artifactId>
<version>1.19.4</version>
</dependency>
May help: I changed the project SDK version from 16 to 1.8 and the problem disappeared! (in Intellij go to Project Structure)
In client yaml file, add the below config
eureka:
client:
register-with-eureka: true
fetch-registry: true
service-url:
defaultZone: http://localhost:8761/eureka/
instance:
hostname: localhost

Spring Cloud Config Client is not fetching automatically configuration from server

I am implementing Spring Cloud config, but the clients are not fetching the config automatically...
When I start up my client gets the data from the server properly, but never retrieves it again.
This is my CloudConfig Server.
#EnableDiscoveryClient
#EnableConfigServer
#SpringBootApplication
public class CloudConfigApplication {
public static void main(String[] args) {
SpringApplication.run(CloudConfigApplication.class, args);
}
}
aplication.yml
eureka:
client:
serviceUrl:
defaultZone: http://localhost:9091/eureka
server:
port: 8888
spring:
application:
name: config-server
cloud:
config:
server:
bootstrap: true
health:
enabled: true
native:
searchLocations: file:${user.dir}/src/main/resources/configs/
profiles:
active: native
Pom.xml
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.8.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>CloudConfig</groupId>
<artifactId>CloudConfig</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>CloudConfig</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Greenwich.SR3</spring-cloud.version>
</properties>
<dependencies>
<!-- 3a) Dependency for spring-cloud-config-Server -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<!-- 3b) Dependency for testing boot projects -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
</dependencies>
<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>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
/src/main/resources/config/CloudConfigClient.yaml
test: aaaaa
test2: 1111
SpringCloud Client
#EnableScheduling
#EnableDiscoveryClient
#SpringBootApplication
#EnableAutoConfiguration
public class CloudConfigClient {
#Value("${test}")
private String myProperty;
public static void main(String[] args) {
SpringApplication.run(CloudConfigClient.class, args);
}
#Bean
public RestTemplate restTemplate(RestTemplateBuilder builder) {
return builder.build();
}
#Scheduled(fixedDelay =1000)
public void printProperty() {
System.out.println("Value of property \"myProperty\": " + myProperty);
}
}
bootstrap.yaml
eureka:
client:
serviceUrl:
defaultZone: http://localhost:9091/eureka
server:
port: 7004
datasource:
driver-class-name: org.h2.Driver
application:
name: CloudConfigClient
cloud:
config:
uri: http://localhost:8888
fail-fast: true
max-attempts: 20
max-interval: 15000
initial-interval: 10000
Pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.8.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Greenwich.SR3</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
This is the ouput log:
2020-11-20 23:33:12.747 INFO 16764 --- [ restartedMain] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8888
2020-11-20 23:33:13.510 INFO 16764 --- [ restartedMain] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=CloudConfigClient, profiles=[default], label=null, version=null, state=null
2020-11-20 23:33:13.510 INFO 16764 --- [ restartedMain] b.c.PropertySourceBootstrapConfiguration : Located property source: CompositePropertySource {name='configService', propertySources=[MapPropertySource {name='file:D:/CloudConfig/src/main/resources/configs/CloudConfigClient.yaml'}]}
...
...
Value of property "myProperty": aaaaa
Value of property "myProperty": aaaaa
if you want your config to be refresh you have to use #RefreshScope spring doc the config won't get update by magic himself because you call #Scheduled.
But base on how you fetch the value in Configuration component they might be limitation and #RefreshScope will not work refreshscope
I suggest create a bean a #ConfigurationProperties and annotate with #RefreshScope when you hit from actuator endpoint /refresh everything should update or maybe combination of #Schedule you might achieved what you want

Netflix Zuul server - /routes endpoint not available

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=*

Categories

Resources