Enviroment:

  • Spring boot 2.3.1.release
  • JDK 1.8

application.properties:

spring.webflux.base-path=/base

controller:

@RestController
@RequestMapping("/test")
public class TestController {

    @GetMapping("/test1")
    public Mono<String> testOne(){
        return Mono.just("testOne");
    }

    @GetMapping("/test2")
    public Mono<String> testTwo(){
        return Mono.just("testTwo");
    }
}
@RestController
public class TestAnotherController {

    @GetMapping("/test3")
    public Mono<String> testThree(){
        return Mono.just("testThree");
    }

    @GetMapping("/test4")
    public Mono<String> testFour(){
        return Mono.just("testFour");
    }
}

after start up project,

expected:

  • visit ip:port/test/test1ip:port/test/test2, HTTP 404;

  • visit ip:port/base/test/test1ip:port/base/test/test2 ,got result;

  • visit ip:port/test3ip:port/test4 HTTP 404;

  • visit ip:port/base/test3ip:port/base/test4,got result;

Actually:

  • visit ip:port/test/test1ip:port/test/test2, got result;

  • visit ip:port/base/test/test1ip:port/base/test/test2 , HTTP 404;

  • visit ip:port/test3ip:port/test4 got result;

  • visit ip:port/base/test3ip:port/base/test4,HTTP 404;

when I put debug point at ,and run as debug,but it is unreachable.

WebFluxProperties#setBasePath

public void setBasePath(String basePath) {
    this.basePath = this.cleanBasePath(basePath);//put debug point here
}

Comment From: wilkinsona

Judging by the sample that you provided for https://github.com/spring-projects/spring-boot/issues/22158, I would guess that you have dependencies on both spring-boot-starter-web and spring-boot-starter-webflux. In this case, as noted in the documentation, Spring MVC and the Servlet-based stack will be used:

Adding both spring-boot-starter-web and spring-boot-starter-webflux modules in your application results in Spring Boot auto-configuring Spring MVC, not WebFlux. This behavior has been chosen because many Spring developers add spring-boot-starter-webflux to their Spring MVC application to use the reactive WebClient. You can still enforce your choice by setting the chosen application type to SpringApplication.setWebApplicationType(WebApplicationType.REACTIVE).

If this does not apply in your situation and you would like us to re-open this issue and spend some more time investigating, please spend some time providing another sample that reproduces this problem. You can share it with us pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.