How to set base url for rest in spring boot? How to set base url for rest in spring boot? java java

How to set base url for rest in spring boot?


With Spring Boot 1.2+ (<2.0) all it takes is a single property in application.properties:

spring.data.rest.basePath=/api

ref link : https://docs.spring.io/spring-data/rest/docs/current/reference/html/#getting-started.changing-base-uri

For 2.x, use

server.servlet.context-path=/api


A bit late but the same question brought me here before reaching the answer so I post it here.Create (if you still don't have it) an application.properties and add

server.contextPath=/api

So in the previous example if you have a RestController with @RequestMapping("/test") you will access it like localhost:8080/api/test/{your_rest_method}

question source: how do i choose the url for my spring boot webapp


For spring boot framework version 2.0.4.RELEASE+. Add this line to application.properties

server.servlet.context-path=/api