This is due an incompatibility between OSS Spring Cloud Gateway and Spring MVC, that is included in Service Registry dependency. They are incompatible because Spring Cloud Gateway is using Spring's Reactive Web support (Spring WebFlux) which conflicts with Spring's Servlet based support (Spring Web MVC).
This can be solved in three different ways as long as the
org.springframework.boot:spring-boot-starter-web dependency is not included in the project:
1. Exclude the OSS
EurekaClientAutoConfiguration.class, which can be done adding the exclude clause to your configuration class as follows:
@EnableAutoConfiguration(exclude={EurekaClientAutoConfiguration.class}).
2. Exclude the
spring-cloud-netflix-eureka-client artifact by changing the following:
<dependency>
<groupId>io.pivotal.spring.cloud</groupId>
<artifactId>spring-cloud-services-starter-service-registry</artifactId>
</dependency>
With:
<dependency>
<groupId>io.pivotal.spring.cloud</groupId>
<artifactId>spring-cloud-services-starter-service-registry</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix-eureka-client</artifactId>
</exclusion>
</exclusions>
</dependency>
3. Enabling bean overriding by setting:
spring.main.allow-bean-definition-overriding=trueNote: If the
org.springframework.boot:spring-boot-starter-web dependency is included in the project there will be no way to by pass the incompatibility and you would need to either split the app into two different ones or use
reactive web instead of Spring MVC.