0

I am working on a existing project where the restControllers has a restmapping @RequestMapping(value = "/test"). There is no base URL added. I have checked all the option where the baseURL gets added but i dont find any in my application. When i run my server. The way to access is <hostname>/rest/v1/test.Application also uses Spring Hateoas. Can you let me know from where/how do these additional /rest/v1 is getting added?

Herr Derb
  • 4,977
  • 5
  • 34
  • 62
Learner
  • 237
  • 4
  • 15

5 Answers5

0

You should find it configured in web.xml or some spring config xml where the servlet mapping url is done.

Arnab Dhar
  • 239
  • 2
  • 15
0

If the project is generated using maven then you should see the application name in pom.xml file something like this.

<groupId>com.test</groupId>
<artifactId>rest</artifactId>
<packaging>war</packaging>
<version>0.1.0.BUILD-SNAPSHOT</version>
<name>rest</name>

and also check web.xml file inside webappp/WEB-INF directory or any other XML config file if you have.

Alien
  • 15,141
  • 6
  • 37
  • 57
0

someone configure it somewhere. search for it in:

  • application.properties
    • server.servlet-path = or spring.data.rest.basePath =
  • Configuration file: just like @Arnad said
  • Configuration Classes: search for a bean named RepositoryRestConfigurer
  • search in whole project:
    • in eclipse use Ctrl + h -> File search
    • in intellij: ctrl + shift + f

ref link : http://docs.spring.io/spring-data/rest/docs/current/reference/html/#_changing_the_base_uri

Tim Diekmann
  • 7,755
  • 11
  • 41
  • 69
shiyar D.
  • 1
  • 1
0

Probably you have one of these property set in the application.properties file:

server.contextPath=/rest/v1  

or

spring.data.rest.basePath=/rest/v1

You can control the base path of you application from there.

Hope it helps!

balag3
  • 665
  • 5
  • 8
0

With very minimal code that you have added, I can only tell you possible place where the base url might have been configured.

  1. On top of your @RestController annotated class.
  2. In case of WebApplicationInitializer it must have been added on ServletRegistration.Dynamic something like below:

    ServletRegistration.Dynamic dispatcher = container
          .addServlet("dispatcher", new DispatcherServlet(context));
    
    dispatcher.setLoadOnStartup(1);
    dispatcher.addMapping("/rest/v1/");
    
Sangam Belose
  • 4,262
  • 8
  • 26
  • 48