How to create a prefix for the url using spring boot

2

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

I would like to know how to create a prefix on the URL that has the project name that serves as the basis for it.

Let's suppose I have a project called app-rht

When opening browser I want to call

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

to add a user, not just

http://localhost:8080/usuario/add

As I'm currently doing in my projects using spring boot.

    
asked by anonymous 26.05.2018 / 19:31

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

Font

    
26.05.2018 / 19:52