简体   繁体   English

spring 带有尤里卡服务器的引导网关

[英]spring boot gateway with eureka server

iam using spring boot gateway with eureka server but when i try to reach some api from gateway it dose not take the path of gateway route it takes the service name我在尤里卡服务器上使用 spring 引导网关,但是当我尝试从网关到达某个 api 时,它不采用网关路由的路径,它采用服务名称

@Configuration
public class SpringCloudConfig {

        @Bean
        public RouteLocator gatewayRoutes(RouteLocatorBuilder builder) {
            return builder.routes()
                    
                //  .route("book", r -> r.path("/book/**").uri("lb://BOOKS"))
    
                    .route("bookstore", r -> r.path("/booksstore/**").uri("lb://BOOKSTORE"))
                     .route("book",
                                r -> r.path("/book/**")
                              
                                        .uri("lb://BOOKS"))
                
                    .build();
        }
    
    }

not working不工作

but if i replace "book" with "books" (service name) it will work但如果我用“书”(服务名称)替换“书”,它就会起作用

According to your configuration, api-gateway by URI "lb://BOOKS" gets from eureka server the path to your service "http://ххх.ххх.ххх.ххх:8080/", and your service seems to have an endpoint "/books", not "/book".根据您的配置,URI“lb://BOOKS”的 api-gateway 从 eureka 服务器获取您的服务路径“http://ххх.ххх.ххх.ххх:8080/”,并且您的服务似乎有一个端点“/books”,而不是“/book”。

Accordingly, you need to change the endpoint in your remote service to "/book".因此,您需要将远程服务中的端点更改为“/book”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM