How to set base url for rest in spring boot?

0 votes
I'm trying to mix mvc and rest in a single spring in 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?
May 22 in Java by kartik
• 27,140 points
1,617 views

1 answer to this question.

0 votes

Hello @kartik,

Set it up in your application.yml (or analogical config file):

spring:
    data:
        rest:
            basePath: /api

As I can remember that's it - all of your repositories will be exposed beneath this URI.

Thank You!!

answered May 22 by Niroj
• 58,500 points

Related Questions In Java

0 votes
1 answer

How to set a timer in Java?

To work on timer in java, you ...READ MORE

answered May 16, 2018 in Java by Daisy
• 8,110 points
122 views
0 votes
1 answer

How to set Encoding in Java ?

Unfortunately, the file.encoding property has to be specified as ...READ MORE

answered May 29, 2018 in Java by Rishabh
• 3,580 points
10,492 views
0 votes
1 answer

How to encode the HTTP URL address in Java?

Use one of the constructors with more ...READ MORE

answered Oct 23, 2018 in Java by Sushmita
• 6,890 points
152 views
0 votes
1 answer

Can anyone show how to implement SortByValue in Tree Map for Java ?

You can't have the TreeMap itself sort on the ...READ MORE

answered Dec 10, 2018 in Java by Sushmita
• 6,890 points

edited Dec 10, 2018 by Sushmita 144 views
0 votes
1 answer

How to redirect to an external URL from controller action in Spring MVC?

Hello @kartik, You can do it with two ...READ MORE

answered May 22 in Java by Niroj
• 58,500 points
2,950 views
0 votes
1 answer

Bean life cycle in Spring Bean Factory Container

Bean life cycle in Spring Bean Factory ...READ MORE

answered Aug 29, 2018 in Java by code.reaper12
• 3,470 points
1,038 views
0 votes
1 answer

How to configure port for a Spring Boot application?

Hello @kartik, You can set port in java ...READ MORE

answered May 22 in Java by Niroj
• 58,500 points
149 views
0 votes
2 answers

How to log SQL statements in Spring Boot?

HI.. try using this in your properties file: logging.level.org. ...READ MORE

answered 1 day ago in Java by SRI

edited 1 day ago by Sirajul 554 views