How to create a prefix for the url using spring boot

Asked

Viewed 764 times

2

I learned to use the spring doing all the configuration in java classes and now I’m migrating to the spring boot 2.0.2.

I would like to know how to create a prefix in the URL that has the name of the project that functions as a base identifier of the project.

Suppose I have a project called app-rht

When open browser I want to call by

http://localhost:8080/app-rht/usuario/add

to add a user and not just

http://localhost:8080/usuario/add

as I am currently doing in my projects using spring boot.

1 answer

4


In the application.properties file, add the following property:

//Se estiver usando Spring Boot 2
server.servlet.contextPath=/app-rht

//Se estiver usando Spring Boot < 2
server.contextPath=/app-rht

Documentation

Source

Browser other questions tagged

You are not signed in. Login or sign up in order to post.