How to set base url for rest in spring boot?

Teimuraz

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't want annotate each controller with @RequestMapping('api/products'), instead, just @RequestMapping('/products').

Mvc controllers should be accessable by example.com/whatever

Is it possible?

(I don't use spring data rest, just spring mvc)

Suroj

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Spring Boot - how do I get the base url of a request

From Dev

Define a base rest controller in spring boot?

From Java

spring boot : How to set spring properties dynamically

From Dev

spring boot : How to set spring properties dynamically

From Dev

How to create a REST service with spring-boot?

From Dev

How to use Firebase with Spring boot REST Application?

From Dev

How to use Firebase with Spring boot REST Application?

From Dev

How to validate Spring Boot Rest response?

From Dev

How to Authenticate each REST request with spring boot

From Dev

Unable to set up basic authentication with Spring Boot REST API

From Dev

Call a function by its REST API URL in Spring Boot

From Dev

Spring boot get application base url outside of servlet context

From Dev

How to set Dynamic base url to https in CodeIgniter?

From Dev

How to set a url base based on your host

From Dev

How to set base url in Java AWS SDK?

From Dev

how to set authentication credentials for JMX in spring boot?

From Java

How to set enableLoggingRequestDetails='true' in Spring Boot

From Dev

Spring Boot - How to set the default schema for PostgreSQL?

From Dev

How to set Handler for embedded Jetty in Spring Boot?

From Dev

How to set up filter chain in spring boot?

From Dev

How to set the data directory of ElasticSearch with Spring Boot

From Dev

How to set up filter chain in spring boot?

From Dev

How to return a set of objects with Spring Boot?

From Dev

how to set defaultLocale programmatically in spring boot

From Dev

How to set ActiveMQ port in Spring Boot?

From Java

How to secure REST API with Spring Boot and Spring Security?

From Dev

How to call MultipartFile Spring REST URL with RestTemplate

From Dev

How to Spring Boot understand URL is String?

From Dev

How do I set JobParameters in spring batch with spring-boot

Related Related

  1. 1

    Spring Boot - how do I get the base url of a request

  2. 2

    Define a base rest controller in spring boot?

  3. 3

    spring boot : How to set spring properties dynamically

  4. 4

    spring boot : How to set spring properties dynamically

  5. 5

    How to create a REST service with spring-boot?

  6. 6

    How to use Firebase with Spring boot REST Application?

  7. 7

    How to use Firebase with Spring boot REST Application?

  8. 8

    How to validate Spring Boot Rest response?

  9. 9

    How to Authenticate each REST request with spring boot

  10. 10

    Unable to set up basic authentication with Spring Boot REST API

  11. 11

    Call a function by its REST API URL in Spring Boot

  12. 12

    Spring boot get application base url outside of servlet context

  13. 13

    How to set Dynamic base url to https in CodeIgniter?

  14. 14

    How to set a url base based on your host

  15. 15

    How to set base url in Java AWS SDK?

  16. 16

    how to set authentication credentials for JMX in spring boot?

  17. 17

    How to set enableLoggingRequestDetails='true' in Spring Boot

  18. 18

    Spring Boot - How to set the default schema for PostgreSQL?

  19. 19

    How to set Handler for embedded Jetty in Spring Boot?

  20. 20

    How to set up filter chain in spring boot?

  21. 21

    How to set the data directory of ElasticSearch with Spring Boot

  22. 22

    How to set up filter chain in spring boot?

  23. 23

    How to return a set of objects with Spring Boot?

  24. 24

    how to set defaultLocale programmatically in spring boot

  25. 25

    How to set ActiveMQ port in Spring Boot?

  26. 26

    How to secure REST API with Spring Boot and Spring Security?

  27. 27

    How to call MultipartFile Spring REST URL with RestTemplate

  28. 28

    How to Spring Boot understand URL is String?

  29. 29

    How do I set JobParameters in spring batch with spring-boot

HotTag

Archive