Serving static resources with Spring WebFlux and Kotlin

When you start a WebFlux project you haven’t the support for static resources, like HTML, CSS and JS files, provided by Spring Boot project. Unfortunately how to solve this simple task isn’t so well documented, so I decided to write this post.

The simplest way I found is to define a resource router as you can see below:

import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.core.io.ClassPathResource
import…