spring boot: separate REST from static content

Viewed 1474

I'm using spring-boot-starter-data-rest and spring-boot-starter-web. I've made a simple project using a CrudRepository, letting spring boot generate the rest request mappings.

Now, I want to add a client -- making the rest calls -- live under ./. Hence, I'm trying to prefix the paths for the rest calls (and only those!) with /api.

I've tried the answers from : How to specify prefix for all controllers in Spring Boot? using settings in the application.properties file

  • server.contextPath=/api/*
  • spring.data.rest.basePath=/api/*.

But still the static content (e.g. index.html, *.js, *.css) is not fetched using ./. There urls are also prefixed by "/api/". The rest calls are properly served under /api/foos.

Is there a way to tell spring not to treat urls that lead to sources located in src/main/resources/public as 'rest-controllers'?

Update

Setting the property
spring.data.rest.basePath=/api/*
works perfectly. (I still had a programmatic bean configuration in my sandbox overriding this setting).

1 Answers
Related