I have Spring Boot (2.0.0 M5) application which provides some REST API. I'd like to implement this API using RouterFunction
s.
While I'm running app using embedded Jetty everything works fine.
When I convert the app to WAR file (following documentation here) and deploy it to Tomcat 8.5 I always get 404
when trying to call any of the endpoints.
I can see in the log that endpoints are recognised:
[ost-startStop-1] s.w.r.r.m.a.RequestMappingHandlerMapping : Mapped "{[/say-hello],methods=[GET]}" onto java.lang.String com.example.demo.DemoController.test()
[ost-startStop-1] o.s.w.r.f.s.s.RouterFunctionMapping: Mapped /api => {
/v1 => {
/status ->
com.example.demo.DemoApplication$$Lambda$189/1904651750@5fdc83e
}
}
But when calling curl -v http://localhost:8080/demo/say-hello
or curl -v http://localhost:8080/demo/api/v1/status
I see default Tomcat 404 page. The path is correct, I rename .war to demo.war
before deploying it.
Did anybody come across similar issue? You can find the code here.
Spring WebFlux is supported on Tomcat, Jetty, Servlet 3.1+ containers, as well as on non-Servlet runtimes such as Netty and Undertow. Spring WebFlux is built on Project Reactor. Project Reactor is the implementation of Reactive Streams specification.
Perhaps the simplest way to deploy a WAR file to Tomcat is to copy the file to Tomcat's webapps directory. Copy and paste WAR files into Tomcat's webapps directory to deploy them. Tomcat monitors this webapps directory for changes, and if it finds a new file there, it will attempt to deploy it.
I'm afraid the WAR deployment model is not supported in Spring Boot for WebFlux at the moment. Spring Framework does support that model (although I'm not sure it supports deploying an app to a non-root context).
You can always create an issue on the Spring Boot issue tracker, but I'm not sure this will be implemented, as deploying to a Servlet container is not the primary focus there (and you can't do that with Netty).
Quick note: adding @EnableWebFlux
is a signal that you'd like to take the WebFlux configuration in your own hands and that Spring Boot should not auto-configure things for you in that space.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With