Joonas Vali :
I'm playing around with Spring 5 features and I'm having some trouble registering RouterFunction
, it will be read, but not mapped. (Tried by throwing exception in the method.)
@Configuration
@RequestMapping("/routes")
public class Routes {
@Bean
public RouterFunction<ServerResponse> routingFunction() {
return RouterFunctions.route(RequestPredicates.path("/asd"), req -> ok().build());
}
}
Going to /routes/asd
results in 404, any clues on what I'm doing wrong?
(I also tried without this @RequestMapping
to /routes
, it also returned 404 for /asd
)
Joonas Vali :
I found the issue.
I had those dependencies both in my pom.xml:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
removed the spring-boot-starter-web dependency and webflux started working properly.
Another solution was to keep the web dependency and exclude tomcat so netty started working:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=474310&siteId=1