How to set base url for rest in spring boot?

后端 未结 18 2359
日久生厌
日久生厌 2020-11-28 03:23

I\'m trying to to mix mvc and rest in a single spring boot project.

I want to set base path for all rest controllers (eg. example.com/api) in a single place (I don\'

18条回答
  •  悲&欢浪女
    2020-11-28 03:55

    For those who use YAML configuration(application.yaml).

    Note: this works only for Spring Boot 2.x.x

    server:
      servlet:
        contextPath: /api
    
    

    If you are still using Spring Boot 1.x

    server:
      contextPath: /api
    

提交回复
热议问题