NoClassDefFoundError or ClassNotFoundException after Migrating Spring Boot App with Kotlin from 1.5.9 to 2.0.0

I’m currently moving one of my Spring Boot applications from 1.5.9 to 2.0.0.

The Application is written in Kotlin and after upgrading I’ve got

java.lang.NoClassDefFoundError: kotlin/reflect/full/KClasses 
java.lang.ClassNotFoundException: kotlin.reflect.jvm.internal.impl.load.kotlin.reflect.ReflectKotlinClass

I posted my problem on Twitter and Stéphan Nicoll from Pivotal gave me the crucial clue. Thanks a lot to Stéphan!

Spring Boot 1 (Spring Framework 4) doesn’t have any support for Kotlin but Spring Boot 2 (Spring Framework 5) now has. Therefore it’s important to add kotlin-reflect as dependency. That’s the dependency that the missing classes is providing.