Unable to find zuul properties in application.yml - spring

Unable to find below zuul properties in application.yml attached the pom.xml.
I hope I added the necessary dependency or do I missing anything.
How to connect the services with gateway.
application.yml
zuul.routes.hello.path=/hello/**
zuul.routes.hello.serviceId=Beginner-Microservice
<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-netflix-zuul</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-zipkin</artifactId>
</dependency>
The reference link
https://javabeginnerstutorial.com/spring-boot/spring-boot-2-microservices-with-netflix-zuul-api-gateway/
The spring cloud version which I have used is
<spring-cloud.version>Finchley.M8</spring-cloud.version>
Kindly help me in this regard

Related

Error starting Spring Cloud Stream with Kinesis

I'm trying to start a new sample project using for process Kinesis Stream but I'm getting the following error:
Exception in thread "-kinesis-consumer-1" java.lang.NoSuchFieldError: logger
at org.springframework.integration.aws.inbound.kinesis.KinesisMessageDrivenChannelAdapter.access$5400(KinesisMessageDrivenChannelAdapter.java:100)
at org.springframework.integration.aws.inbound.kinesis.KinesisMessageDrivenChannelAdapter$ShardConsumer.lambda$execute$0(KinesisMessageDrivenChannelAdapter.java:941)
And those are my pom dependencies:
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-kinesis</artifactId>
<version>LATEST</version>
</dependency>
<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>com.amazonaws</groupId>
<artifactId>aws-java-sdk-kinesis</artifactId>
<version>1.11.632</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream</artifactId>
<scope>test</scope>
<classifier>test-binder</classifier>
<type>test-jar</type>
</dependency>
</dependencies>
The sample code of Spring Cloud with Kinesis is outdated, so I tried use newest dependencies.
Anyway, someone can help?
You probably try to use the latest Spring Boot 2.4.x which brings for us Spring Integration 5.4 already. And this one is not compatible with the latest Spring Integration AWS, which is still based on the Spring Integration 5.3.x.
Let's see if you still can stick with Spring Boot 2.3.x!

Spring boot config client not resolving config server

Config client cannot resolve configuration property and cannot connect to config server.
Here's my service application.properties file:
spring.application.name = idmanager-service
spring.cloud.config.uri = http://localhost:8888
server.port=8081
#enable actuator endpoints
management.endpoints.web.exposure.include=*
management.endpoint.health.show-details=always
info.app.name=Id management Application
info.app.description=managing citizens identities
info.app.version=0.1.0
The dependencies in pom.xml:
<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>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<!-- Lmobok Dependency-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.2</version>
<scope>provided</scope>
</dependency>
<!-- / Lmobok Dependency-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<!--<version>RELEASE</version>-->
<scope>compile</scope>
</dependency>
<!-- Eureka discovery client-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-commons</artifactId>
<version>2.2.2.RELEASE</version>
</dependency>
<!-- Config client-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<!-- Actuator -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies>
The config server and the discovery server started successfully and other services are successfully registered.
Here's the config server application.properties file:
server.port=8888
spring.cloud.config.server.git.uri=file:./src/main/resources/myConfig
The application.properties file in myConfig folder:
global=xxxxx
Other services are successfully registered and fetching config server:
c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8888
I resolved this issue by fixing Spring cloud version like below:
<spring-cloud.version>Hoxton.SR3</spring-cloud.version>
Then I specified the Spring cloud dependency version using dependency management:
<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>

Spring Boot with Hystrix

I am using Spring Boot with Hystrix for my university project.
The problem I have is when I add Netflix Hystrix dependency to pom.xml file and run the program, It throws an Error called AbstractMethodError : null, but without Netflix Hystrix dependency program runs without any error. How can I slove this?
These are my dependencies
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
This is due to dependency mismatch. Application is trying to call an abstractt method but it doesn't find that method. So, it is throwing the null exception.
Use two dependency netflix-hystrix-dashboard and hystrix as below.
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
</dependency>

Application insight configuration for spring boot is not working

I am using spring boot version 2.0.0.
and I am using applicationInsight-web and core jar 2.1.0.
I have put instrumantation key in applicaionInsight.xml also.
Please refer to https://learn.microsoft.com/en-us/azure/application-insights/app-insights-java-get-started#4-add-an-http-filter
It shows how to configure Application Insights Java SDK for SpringBoot Applications.
Here are the configurations for me to make Spring-cloud + Azure Application Insight.
pom.xml
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>applicationinsights-spring-boot-starter</artifactId>
<version>1.2.0-BETA</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>applicationinsights-logging-logback</artifactId>
<version>2.4.0-BETA</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>
<dependency>
<groupId>io.opentracing.brave</groupId>
<artifactId>brave-opentracing</artifactId>
</dependency>
and dependenciesManagement
<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>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>spring-cloud-azure-dependencies</artifactId>
<version>1.1.0.RC5</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
logback-spring.xml
<appender name="aiAppender"
class="com.microsoft.applicationinsights.logback.ApplicationInsightsAppender">
<instrumentationKey>YOUR_INSTRUMENTATION_KEY</instrumentationKey>
</appender>
application.yml
azure:
application-insights:
instrumentation-key: YOUR_INSTRUMENTATION_KEY
Good luck!

use Zipkin+ElasticSearch+Sleuth+rabbitMQ can't find "services"

SpringCloud version:Dalston.SR1,
rabbitMQ version:3.6.10,ElasticSearch version:6.2.4
There was nothing unusual when I use MySQL as a storage.
Now I use ElasticSearch.I can't find any services.
I lost something?
here is the picture:
application.properties
server.port=11008
spring.application.name=microservice-zipkin-stream-server-es
spring.sleuth.enabled=false
spring.sleuth.sampler.percentage=1.0
zipkin.storage.StorageComponent = elasticsearch
zipkin.storage.type=elasticsearch
zipkin.storage.elasticsearch.cluster=elasticsearch-zipkin-cluster
zipkin.storage.elasticsearch.hosts=127.0.0.1:9300
zipkin.storage.elasticsearch.max-requests=64
zipkin.storage.elasticsearch.index=zipkin
zipkin.storage.elasticsearch.index-shards=5
zipkin.storage.elasticsearch.index-replicas=1
spring.rabbitmq.host=192.168.0.162
spring.rabbitmq.port=5672
spring.rabbitmq.username=basefrm
spring.rabbitmq.password=basefrm
eureka.instance.hostname=192.168.0.162
eureka.client.serviceUrl.defaultZone=http://192.168.0.162:8761/eureka/
management.security.enabled=false
pom.xml
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-zipkin-stream</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rabbit</artifactId>
</dependency>
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-autoconfigure-ui</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin</artifactId>
<version>2.4.1</version>
</dependency>
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-autoconfigure-storage-elasticsearch-http</artifactId>
<version>2.4.1</version>
<optional>true</optional>
</dependency>
You're using an ancient version of Sleuth, can you please upgrade? Why do you provide Zipkin's version manually? Also as far as I see you're using the Sleuth's Zipkin server (that is deprecated in Edgware and removed in Finchley). My suggestion is that you stop using the Sleuth's Stream server (you can read more about this here https://cloud.spring.io/spring-cloud-static/Edgware.SR3/single/spring-cloud.html#_sleuth_with_zipkin_via_rabbitmq_or_kafka).
<dependencyManagement> (1)
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${release.train.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependency> (2)
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>
<dependency> (3)
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-rabbit</artifactId>
</dependency>
1) In order not to pick versions by yourself it’s much better if you add the dependency management via the Spring BOM
2) Add the dependency to spring-cloud-starter-zipkin - that way all dependent dependencies will be downloaded
3) To automatically configure rabbit, simply add the spring-rabbit dependency

Resources