https://kotlinlang.org logo
#spring
Title
# spring
a

antonarhipov

07/06/2022, 10:50 AM
📢 hello folks! We are in process of updating the Spring-Kotlin tutorial in our documentation. I think it’s a good time to ask for the feedback from the community. We don’t plan to make it super-comprehensive though, the goal is rather to show how to get started with Kotlin in the Spring projects and cover some of the obvious use cases. Here I have the first draft. Please let me know what do you think about in the thread 🧵
👍 3
m

mbonnin

07/06/2022, 12:16 PM
Is there a link somewhere to the final Github repo? Or even better, a Github template?
a

antonarhipov

07/06/2022, 12:20 PM
So far, only this, only with the final code state. There are the intermediate commits as well though: https://github.com/antonarhipov/kotlin-spring-demo
👌 1
m

mbonnin

07/06/2022, 12:22 PM
Nice! I'd put the link as a preamble
a

antonarhipov

07/06/2022, 12:23 PM
I will probably split the repository into branches for each stage of the tutorial in the final version
m

mbonnin

07/06/2022, 12:24 PM
That'd be nice althoug TBH a lot of work 😅
a

antonarhipov

07/06/2022, 12:24 PM
it’s for the good cause 😉
💙 1
m

mbonnin

07/06/2022, 12:25 PM
Yup 🙂
e

Emil Kantis

07/07/2022, 12:41 PM
I mean, Spring Initializr puts some outdated stuff into the gradle files.. I would raise an issue or contribute a fix to that.. Or at least mention what it does wrong in the guide
1
a

antonarhipov

07/07/2022, 12:43 PM
@Emil Kantis can you give an example? I can’t recall anything like that atm
e

Emil Kantis

07/07/2022, 12:43 PM
Also it would feel more "kotlin" to me to use Webflux and DSL routing rather than annotation-driven code.. But I guess it depends on the audience 🙂
Copy code
mplementation("org.jetbrains.kotlin:kotlin-reflect")  Kotlin reflection
library, required for working with Spring
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
Adding stdlib is no longer needed, gradle plugin adds it automatically and I would change the kotlin reflect dependency to
implementation(kotlin("reflect"))
🙏 1
a

antonarhipov

07/07/2022, 12:45 PM
Yeah. Webflux is not something we want to throw at the users right from the beginning, I think. We do plan to develop this tutorial further, so yeah, I think we will bring in the dsl a bit later
👍 3
s

sreich

07/07/2022, 3:46 PM
if your goal is to get more people using kotlin and spring, i recommend looking at it from the lens of "how to get java and kotlin to coexist in a spring environment". (kapt) But also, higher priority at least for me, is how to get hibernate/JPA to play nicely with kotlin. And I mean real-world entities, not "everything is so simplistic wee, we stored 2 strings and it's so nice" that I frequently see I've had to scour a crazy number of resources to get the information I needed just to convert my hibernate JPAs over to kt. Many would say totally different things. Then I ran into an Intellij bug which is unfixed, for embeddable entities that gives a false positive for an inspection And right now, I'm running into a failure of smart casting because of the all-open plugin, which i'm wondering if there's a workaround for
👍 1
c

corneil

07/07/2022, 6:30 PM
I would suggest adding
@Column
to show custom names, many organizations have specific naming conventions or may be using existing existing tables. Also create separate interface for MessageService so that Controller depends on interface and not implementation
👀 1
s

sdeleuze

07/08/2022, 6:04 PM
Nice, maybe renaming
MessageResource
to
MessageController
would be more idiomatic?
👍 1
I like the fact you use Spring Data JDBC
s

sreich

07/08/2022, 6:08 PM
i agree with the
@Column
, be more in line with what most people are doing (including my orgs code)
s

sdeleuze

07/08/2022, 6:08 PM
You could use Kotlinx Serialization and exclude Jackson dependencies.
1
👍 3
4 Views