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…

--

--

--

Open-space invader, bug hunter and software writer

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Davide Cerbo

Davide Cerbo

Open-space invader, bug hunter and software writer

More from Medium

Springboot Kotlin and Redis — Great partners

JDK 17 — Unsupported Class File Major Version

Building async API using Ktor & Kotlin Coroutines

Web Scraper API Using Vert.x and Jsoup in Kotlin That Can be Monetized