我正在尝试使用spring-boot-starter-webflux和reactive Netty创建一个spring-boot-2rest api。我正在尝试按照Spring-Boot-2中定义的application.yml中定义的新属性来设置上下文路径。
server.servlet.context-path: /api # Define the server context path无论Webflux看起来如何,Netty并不使用/识别application.yml中定义的这个属性。
如果我使用spring-boot-starter-web和Tomcat作为默认服务器,那么它工作得很好,可以正确地识别上下文路径。
在Spring Boot 2 documentation中没有找到任何关于Netty的上下文路径的内容。
Spring Boot Version = 2.0.3.RELEASE如果我遗漏了什么,或者这是Webflux Netty的默认行为,请告诉我。
发布于 2018-09-16 11:51:08
配置上下文路径是特定于servlet的。当使用WebFlux时,配置属性被重命名为server.servlet.context-path,并且仅用于基于servlet的部署。
你可以阅读下面的帖子,了解如何在webflux中处理上下文路径,请参阅评论
https://github.com/spring-projects/spring-boot/issues/10129#issuecomment-351953449
发布于 2020-08-22 00:54:00
在spring boot 2.3.x中,您可以设置spring.webflux.base-path属性
发布于 2021-08-27 13:07:11
它对我来说很有效
spring.webflux.base-path=/myPath
但仅当在此注释中添加提示时:https://stackoverflow.com/a/67840678/8376373
它建议注入一个WebFluxProperties Bean
@Bean
fun webFluxProperties(): WebFluxProperties {
return WebFluxProperties()
}https://stackoverflow.com/questions/52342051
复制相似问题