ashraf revo
ashraf revo

Reputation: 817

change spring boot 2.0 context-path

I want to change context path for spring boot 2 for example i want to serve on http://localhost:8080/test/

i mean it not working for me with spring-boot-starter-webflux:2.0.0.RELEASE

it only working with spring-boot-starter-web::2.0.0.RELEASE

I have tried

server.servlet.context-path=/test

But nothing happened to me still serve on url http://localhost:8080/

Upvotes: 6

Views: 18816

Answers (5)

Black
Black

Reputation: 10407

In spring boot 2.3.x you can set spring.webflux.base-path property

spring.webflux.base-path=/path

Upvotes: 6

Duncan O. N.
Duncan O. N.

Reputation: 816

In reference to Spring Boot 2.x. below configuration apply for application.yml

server:
  port: 8080
  servlet:
    context-path: /test

For application.properties configuration are

server.port=8080
server.servlet.context-path= /test

Upvotes: 3

pixel
pixel

Reputation: 26513

For use cases where WebFlux application is behind load balancer/proxy you can use dedicated class - ForwardedHeaderTransformer that will extract path context from X-Forwarded-Prefix and will add it to ServerHttpRequest.

Doing so you won't need to modify global context-path (which does not make sense in WebFlux)

More about it here: https://docs.spring.io/spring/docs/current/spring-framework-reference/web-reactive.html#webflux-web-handler-api

Upvotes: 2

tObi
tObi

Reputation: 1942

If you use the servlet API then the property is now called

server.servlet.context-path=/myapp

Upvotes: 12

Kedar Joshi
Kedar Joshi

Reputation: 1511

As confirmed by Andy Wilkinson @andy-wilkinson of the Spring Boot team via Gitter

There’s no concept of context path in WebFlux so there’s no equivalent property

i.e WebFlux doesn't support context path configuration

Upvotes: 7

Related Questions