Eureka Client and spring integration - spring

I am trying to make my Spring application as Discovery Client. But the moment I add the following dependency
<dependency>
<groupId>com.netflix.eureka</groupId>
<artifactId>eureka-client</artifactId>
<version>1.1.37</version>
</dependency>
the GWT webapp fails to launch with 503 Service unavailable. Can netflix Eureka be used only with spring boot or spring cloud applications?

Resolved:
The version that I was using was very old. updated the version to 1.1.159 and everything is working fine.

Related

Spring cloud Consul for non spring boot web app

I have microservice written in spring boot that is not web app (no spring-boot-starter-web dependency).
It consumes event from message bus and do some other calculation not related to web request at all.
Still I want it to be registered with Hashicorp Consul using spring cloud service registration (for external configuration and health checks) but it only registered automatically when I add the spring-boot-starter-web dependency.
Any ideas how to use spring-cloud-starter-consul without web dependency?

Which is the best way for the routs uri in spring boot except zuul and spring cloud gateway

I am upgrading the spring boot 1.3.7.RELEASE to 2.5.12 and spring framework 5.3.18 in my spring boot microservice based project we have upgrade successfully with all service except gateway service when i am unabling t add zuul dependency because its maintenance mode that why we have implemented spring cloud gateway then i am getting below issue.
***************************
APPLICATION FAILED TO START
***************************
Description:
Spring MVC found on classpath, which is incompatible with Spring Cloud Gateway.
Action:
Please set spring.main.web-application-type=reactive or remove spring-boot-starter-web dependency.
Wwhat we need to do implementation for best way?
We have fix the routing issue using the spring cloud gateway.
Please add dependency in the pom.xml
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-gateway</artifactId> </dependency>
bootstrap.yml
spring:main:web-application-type:reactive
Thanks you guys for supporting.

Implementing Spring Cloud Gateway In The Same Project

I provide an api for other microservices in my spring boot microservice and I want to put a spring-cloud-gateway in front of this microservice.
I have reviewed the well-known spring document (https://spring.io/guides/gs/gateway/) but as far as I understand it requires me to launch the cloud gateway in a separate project. But I want to run the RouteLocator bean there in my microservice. Not in a separate project, but in the same project.
When I use it in the same project, I get a warning like this
"Spring MVC found on classpath, which is incompatible with Spring Cloud Gateway at this time. Please remove spring-boot-starter-web dependency."
Later, as he said in the warning, I remove the spring-boot-starter-web dependency, even coming in other projects, excluding them from there like this
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web-services</artifactId>
<exclusions>
<exclusion>
<artifactId>spring-boot-starter-web</artifactId>
<groupId>org.springframework.boot</groupId>
</exclusion>
</exclusions>
</dependency>
This time I logically get the error
"org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [com.company operations.Service operationsApplication]; nested exception is org.spring. .core.NestedIOException: Failed to load class [javax.servlet.Filter]; nested exception is java.lang.ClassNotFoundException: javax.servlet.Filter
".
We deleted the core library from the project that should provide web api service :D
As a result, can I use cloud gateway in the same project? What is the reason and logic for not using it?
If it is not possible to use it in the same project, how should the well-known practices of gateway be, should I put a gateway in front of each api microservice, or should I have a single gateway in my project consisting of more than one microservice?
You can start gateway in the same project, but this is a webflux based project.
From documentation
Spring Cloud Gateway is built on Spring Boot 2.x, Spring WebFlux, and Project Reactor. As a consequence, many of the familiar synchronous libraries (Spring Data and Spring Security, for example) and patterns you know may not apply when you use Spring Cloud Gateway. If you are unfamiliar with these projects, we suggest you begin by reading their documentation to familiarize yourself with some of the new concepts before working with Spring Cloud Gateway.
and
Spring Cloud Gateway requires the Netty runtime provided by Spring Boot and Spring Webflux. It does not work in a traditional Servlet Container or when built as a WAR.
so you should have used spring-boot-starter-webflux instead of spring-boot-starter-web.
Alternatively, if you need to use traditional Spring MVC, consider using Spring Netflix Zuul. This project is currently in maintenance mode and Spring Gateway is the successor of it, but it should work.
To add to sawim's answer regarding using Spring MVC, in the case that your project uses spring-boot >=2.4, spring-cloud-netflix-zuul won't be compatible since it is not included with spring-cloud as of version 2020.0.
In that case, a possible alternative would be to setup a proxy using spring-cloud-gateway in an MVC project using spring-cloud-gateway-mvc, which is compatible with spring-boot-starter-web.

how to setup the Spring Boot Admin Server via war-deployment in a external tomcat?

I'm trying to set up spring-boot-admin via war deployment. for war i'm not able to see the client application in spring boot admin dashboard.
I've tried with spring boot version 2.1.6 and tomcat version 8.5.47 but i'm not able to see the client application in dashboard.
My client application POM
<version>1.0.0</version>
<packaging>war</packaging>
<name>spring-boot-admin-client</name>
<description>Demo project for Spring Boot Admin - Client</description>
Dependencies I have used:
spring-boot-starter-actuator
spring-boot-admin-starter-client
spring-boot-starter-security
spring-boot-starter-test
spring-boot-starter-web
Not getting any error message but client application i'm not able to see it in spring-boot-admin dashboard.
Have u configured spring.boot.admin.client.instance.service-url property in client application?
Generally when Spring Boot Client is installed on external tomcat, SBA predicts the actuator endpoints path as http://server:port/actuator while the actual path is http://server:port/context-root/actuator.
This is where spring.boot.admin.client.instance.service-url property comes to the rescue. spring.boot.admin.client.instance.service-url should be set as http://server:port/context-root

How to deploy Spring Cloud Gateway 2.1 on Jboss or Tomcat?

I want to a deploy Spring Cloud Gateway but it is built on Spring Framework 5, Project Reactor.
Can I create a WAR file and deploy it on a traditional application server such as Jboss or Tomcat.
The Spring documentation in this page says it is possible.
Spring WebFlux is supported on Tomcat, Jetty, Servlet 3.1+ containers
Note:
this is Spring Cloud Gateway project link
https://spring.io/projects/spring-cloud-gateway
I don't think this is possible, as Spring Cloud Gateway is itself a Spring Boot WebFlux application and this use case is only supported with embedded servers, as mentioned in the Spring Boot reference documentation.

Resources