spring-projects / spring-projects/spring-data-rest

Adding RequestMapping("/**") overrides spring data rest base path [DATAREST-940]

Open
#1,310 0 comments 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 31, 2020.

in: repository type: bug type: task
Dominant language
Java
Stars
958
Forks
568
PR merge metrics
No merged PRs in 30d

Description

Florian opened DATAREST-940 and commented

Hello,

I have a simple Spring Boot app with a CrudRepository annotated with @RepositoryRestResource to enable REST services on that repository.

I also customized the REST API base path with the following configuration:

spring:
  data:
    rest:
      base-path: /api

In the other hand, I got a custom @RestController with @RequestMapping("/**") because my app need to catch all pathes (except the /api path).

The thing is, /** is matching everything even my API path. So I'am unable to request my API.

Is that the desired behavior ?
Is there any way to make /** not matching /api, or make the RepositoryRestResource match first ?

I tried the following without success:

@Configuration
public class WebMvcConfig extends WebMvcConfigurerAdapter {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
        super.addResourceHandlers(registry);
    }

}

Affects: 2.5.4 (Hopper SR4)

2 votes, 2 watchers

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.