更改spring boot 2.0 context-path

ash*_*evo 2 spring spring-boot spring-webflux

我想更改spring boot 2的上下文路径,例如我想在http:// localhost:8080/test /上提供服务

我的意思是它不适合我使用spring-boot-starter-webflux:2.0.0.RELEASE

它只与spring-boot-starter-web :: 2.0.0.RELEASE一起使用

我试过了

server.servlet.context-path=/test
Run Code Online (Sandbox Code Playgroud)

但是我没有发生任何事情仍然在url http:// localhost:8080 /

tOb*_*Obi 8

如果使用servlet API,则现在调用该属性

server.servlet.context-path=/myapp
Run Code Online (Sandbox Code Playgroud)

  • 这将适用于Spring MVC。它不适用于WebFlux。 (4认同)

Ked*_*shi 7

正如Spring Boot 团队的 Andy Wilkinson @andy-wilkinson通过 Gitter 确认的那样

WebFlux 中没有上下文路径的概念,因此没有等效的属性

即 WebFlux 不支持上下文路径配置


Bla*_*ack 6

在 spring boot 2.3.x 中,您可以设置 spring.webflux.base-path 属性

spring.webflux.base-path=/path
Run Code Online (Sandbox Code Playgroud)