During my recent work which requires me to work on a backend. It’s a Springboot with Kotlin backend and Database is mongodb. This backend is integrating some GCP APIs.
Since there is a need that some collections would have bidirectional relationship. In this case, it may cause another issue that’s the infinite recursion exception.
Like the post here:
https://stackoverflow.com/questions/44093228/infinite-recursion-issue-with-dbref-lazy-true
However, it’s not the issue that I want to address in this post.
The topic, I want to talk about is …
Kotlin has classes and their members
https://kotlinlang.org/final
by default, which makes it inconvenient to use frameworks and libraries such as Spring AOP that require classes to beopen
.
In this case, we need to leverage All-open compiler plugin and makeorg.springframework.data.mongodb.core.mapping.Document
to be open.
What you need to do is, you need to add some configurations in build.gradle.kts
plugins {
id("org.jetbrains.kotlin.plugin.allopen") version "1.8.21"
}
allOpen {
annotation("org.springframework.data.mongodb.core.mapping.Document")
}
For more information, you can refer these two links…
搶先發佈留言