Java how to set context path in spring boot

Java how to set context path in spring boot

To set the context path of a Spring Boot application, you can use the server.servlet.context-path property in the application.properties file.

For example, if you want to set the context path to /myapp, you can add the following line to your application.properties file:

‮:ot refer‬lautturi.com
server.servlet.context-path=/myapp

Alternatively, you can set the context path programmatically using the setDefaultContextPath() method of the SpringApplication class.

import org.springframework.boot.SpringApplication;

// ...

SpringApplication app = new SpringApplication(MyApplication.class);
app.setDefaultContextPath("/myapp");
app.run();

This will set the context path of the application to /myapp.

Created Time:2017-11-03 23:27:11  Author:lautturi