I've noticed in my Spring Boot WebFlux app, that the mapping is different than MVC.
In MVC, I could add a RestController("/prefix")
so that my methods would all be prefixed with /prefix
. But in WebFlux, this doesn't work.
Is this by design?
Note - I swapped out the Mono<>
return type to see if it made a difference, in case there was some other introspection being done here.
For example, this is the controller -
@RestController("/api/user")
public class UserController {
private UserService service;
public UserController(UserService service) {
this.service = service;
}
@GetMapping("/me")
public Map<String, Object> whoami(@AuthenticationPrincipal OAuth2User oauth2User) {
HashMap<String, Object> response = new HashMap<>();
if (null != oauth2User) {
response.put("userName", oauth2User.getName());
response.put("userAttributes", oauth2User.getAttributes());
return response;
} else {
response.put("userName", "anonymous");
return response;
}
}
...
And the mapping is not found where I'd expect it.
I think the comment about dependencies right - One of these is pulling in a conflict.
dependencies {
implementation project(":shared:domain")
implementation 'org.springframework.cloud:spring-cloud-starter-gateway',
'org.springframework.cloud:spring-cloud-starter-security',
'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client',
'org.springframework.boot:spring-boot-starter-webflux',
'org.springframework.boot:spring-boot-starter-oauth2-client',
'org.zalando:problem-spring-webflux:0.25.0',
"com.okta.sdk:okta-sdk-api:${oktaVersion}"
runtime "com.okta.sdk:okta-sdk-impl:${oktaVersion}",
"com.okta.sdk:okta-sdk-httpclient:${oktaVersion}"
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
}