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?
5 Answers
You should find it configured in web.xml
or some spring config xml
where the servlet mapping url is done.

- 239
- 2
- 15
-
I am using webAppIntializer and have not set basepath URL anywhere – Learner Jul 06 '18 at 07:45
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.

- 15,141
- 6
- 37
- 57
someone configure it somewhere. search for it in:
- application.properties
server.servlet-path
= orspring.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

- 7,755
- 11
- 41
- 69

- 1
- 1
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!

- 665
- 5
- 8
With very minimal code that you have added, I can only tell you possible place where the base url might have been configured.
- On top of your
@RestController
annotated class. 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/");

- 4,262
- 8
- 26
- 48