user14099235
user14099235

Reputation:

Spring boot gateway error - Unable to find RoutePredicateFactory with name path

I'm using Spring boot cloud gateway. Spring version is 2.3.4.RELEASE My eureka server is working well and other configurations are working well. But when I gonna run the cloud gateway the Spring gives an error like bellow.

org.springframework.context.ApplicationContextException: Failed to start bean 'eurekaAutoServiceRegistration'; nested exception is reactor.core.Exceptions$ErrorCallbackNotImplemented: java.lang.IllegalArgumentException: Unable to find RoutePredicateFactory with name path

My cloud gateway configurations are like this.

spring:
  cloud:
    gateway:
      routes:
        - id: sripy-client
          uri: localhost:8080
          predicates:
            - path=/client/
  application:
    name: API-GATEWAY
eureka:
  client:
    register-with-eureka: true
    fetch-registry: true
    service-url:
      defaultZone: http://localhost:8761/eureka/
  instance:
    hostname: localhost
server:
  port: 8989

and porm.xml like this.

<?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.4.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example.gateway</groupId>
    <artifactId>example.gateway</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>example.gateway</name>
    <description>example gateway</description>

    <properties>
        <java.version>1.8</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.cloud</groupId>
            <artifactId>spring-cloud-starter-gateway</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </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>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </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>

please help me to resolve this issue!

Upvotes: 4

Views: 9159

Answers (2)

Batman
Batman

Reputation: 57

the first letter of Path must be capital. this resolved my issue.

incorrect:

spring.cloud.gateway.routes[0].predicates[0]=path=/api/product

correct:

spring.cloud.gateway.routes[0].predicates[0]=Path=/api/product

Upvotes: 0

Mafei
Mafei

Reputation: 3819

The problem is your predicates > path in yml file. the first letter must be a capital letter, in your case p of the path must be capital like this - Path=/client/

Entire yml file

spring:
  cloud:
    gateway:
      routes:
        - id: sripy-client
          uri: localhost:8080
          predicates:
            - Path=/client/ #first letter must be a capital letter 
  application:
    name: API-GATEWAY
eureka:
  client:
    register-with-eureka: true
    fetch-registry: true
    service-url:
      defaultZone: http://localhost:8761/eureka/
  instance:
    hostname: localhost
server:
  port: 8989

Upvotes: 25

Related Questions