I am learning webflux and I would like to know how to serve static content on a MicroService using webflux but I didn´t find information to do it.
相关问题
- WebTestClient not injected
- Dealing with parallel flux in Reactor
- Issue with Spring Webflux webclient , nothing happ
- Type interference issue with the WebFlux WebTestCl
- WebFilter in WebFlux application
相关文章
- Spring 5 Web Reactive - Hot Publishing - How to us
- How to limit request payload size using Spring Web
- How to view response from Spring 5 Reactive API in
- change spring boot 2.0 context-path
- How to use Jaeger with Spring WebFlux?
- django-pipeline and s3boto storage don't seem
- null principal returned by ServerRequest in webflu
- Spring WebFlux, unit testing Mono and Flux
Try this
Spring Web Flux & public static web resources configuration
put public static web resources into the
public-web-resources
folder:configure Spring Boot 2.0,
application.yaml
:configure maven-resources-plugin,
pom.xml
:Thanks wildloop worked for me with following properties:
Spring boot adds following log line:
And it works as welcome page for http://localhost:port/myapp/
Wish there was a way to invoke it on
/myapp/docs
Juan Medina is right. I just want to make it even more clear and provide a reference link.
In fact, you just have to add a RouterFunction bean to handle static resources. You don't have to implement your own RouterFunction because
RouterFunctions.resources("/**", new ClassPathResource("static/"));
gives what you want.All I do is to add this piece of code:
Whatever unrecoginized requests will fall into the static router.