r/SpringBoot • • Jan 04 '26

Question Java vs Kotlin for Spring Boot

At my company, we have pretty extensive (15+ years) experience with Sprint Boot and the Spring Framework in general, all of it done using Java with the occasional script divergence to Groovy. This backend stack provides APIs to mobile clients, the Android portion of which is largely coded using Kotlin/Jetpack Compose. Once upon a time our Android app was coded in Java using xml views, but after getting a taste of Kotlin and compose, we never looked back. We're currently sizing up a backend migration from Spring Boot 3.x to 4.x and wondering whether to take a stab at converting some of our Gradle microservice modules to Kotlin.

The smart money bet would be not to launch a campaign on two fronts, but having cut our teeth on the Android conversion, the Spring Boot one's doesn't seem as daunting, given that we can tackle one microservice at a time. The primary concern is with serialization, since with microservices communicating via Spring Integration/ Kafka / Spring Batch, there's a good deal of that going on. Spring Boot 4 apparently took a step forward towards making Java-Kotlin serialization play nice, but wondering whether others who have both Java and Kotlin in their Spring stack have found any surprising pitfalls or gotchas.

16 Upvotes

14 comments sorted by

View all comments

Show parent comment

3

u/External_Mushroom115 Jan 04 '26

As said, do not convert *.java to *.kt by default. There are no gains unless it's a really ugly piece of code that could benefit from a bit of redesign, in which case the Java-to-Kotlin conversion feature in IntelliJ in just a starting point!

What runtime gremlins are you thinking about?

For static analysis on Kotlin sources, have a look at Detekt. For linting (formatting) of Kotlin sources there is KtLint (or Kfmt). JaCoCo is pretty good at test coverage for Kotlin sources. If accuracy is an issue, replace JaCoCo with Kover. The latter supports the same XML report as JaCoCo.