【问题标题】:Prefix all endpoints with "/api" or another prefix, in spring reactive web (webflux)在 spring 响应式 Web (webflux) 中为所有端点添加“/api”或其他前缀
【发布时间】:2021-01-30 22:43:14
【问题描述】:

我在一个 Spring 响应式 Web 项目中有一组 RestController,我想在不同环境中为所有控制器添加前缀“api”或“test-api”。

我尝试使用server.servlet.context-path=/api,但它不适用于在 Netty 服务器上运行的 Spring 反应式 Web (webflux)

【问题讨论】:

    标签: java spring spring-boot netty spring-webflux


    【解决方案1】:

    在 Spring Boot 2.3 中添加了以下属性以使用 webflux 实现此目的

    spring.webflux.base-path
    

    发行说明:https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.3-Release-Notes#configurable-base-path-for-webflux-applications

    【讨论】:

      【解决方案2】:

      您是否尝试过在 @RequestMapping 中使用占位符,例如 @RequestMapping("${foo.bar}") ?

      谢谢

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2023-02-14
        • 2020-07-24
        • 2021-01-17
        • 2018-10-31
        • 2018-12-17
        • 2018-11-22
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多