Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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/

like image 239
ashraf revo Avatar asked Mar 09 '18 11:03

ashraf revo


People also ask

How do you change the context path of a Spring Boot application?

Just like many other configuration options, the context path in Spring Boot can be changed by setting a property, server. servlet. context-path. Note that this works for Spring Boot 2.

Where is context path in Spring Boot?

Simply put, the context path is a name with which a web application is accessed. It is the root of the application. By default, Spring Boot serves the content on the root context path (“/”).

How do I change the context path in STS?

1.1 Right click on the project, select Properties , Web Project Settings , update the context root here. 1.2 Remove your web app from the server and add it back. The context root should be updated. 1.3 If step 2 is failing, delete the server, create a new server and add back the web app.

Can we have multiple context path in Spring Boot?

In order to have multiple context paths, you're limited to deploying the application multiple times with that convenient property set to what you want for each deployment. However, this is resource expensive because you're spinning up two applications for every one application you would normally spin up.


2 Answers

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

server.servlet.context-path=/myapp
like image 190
tObi Avatar answered Oct 21 '22 07:10

tObi


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

like image 36
Kedar Joshi Avatar answered Oct 21 '22 07:10

Kedar Joshi