admin管理员组文章数量:1122832
After update jackson kotlin module from 2.17 to 2.18 I have strange errors.
DTO is
data class StopWordModifyRequest(
@field:NotEmpty
@field:Size(min = 2, max = 255)
val word: String,
) : Serializable
test
mvc
.post(API_ROUTE) {
addCommonHeaders(KNOWN_USER_ID, ADMIN_ROLE)
content = """
{
"word": "childTest"
}
"""
}.andExpect { status { isCreated() } }
it works in 2.17, but error in 2.18:
Body = {"message":"Request body is invalid","details":[{"name":null,"description":"Cannot construct instance of `x.y.z.StopWordModifyRequest` (although at least one Creator exists): cannot deserialize from Object value (no delegate- or property-based Creator)\n at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 3, column: 25]"}]}
I can't google it quickly
After update jackson kotlin module from 2.17 to 2.18 I have strange errors.
DTO is
data class StopWordModifyRequest(
@field:NotEmpty
@field:Size(min = 2, max = 255)
val word: String,
) : Serializable
test
mvc
.post(API_ROUTE) {
addCommonHeaders(KNOWN_USER_ID, ADMIN_ROLE)
content = """
{
"word": "childTest"
}
"""
}.andExpect { status { isCreated() } }
it works in 2.17, but error in 2.18:
Body = {"message":"Request body is invalid","details":[{"name":null,"description":"Cannot construct instance of `x.y.z.StopWordModifyRequest` (although at least one Creator exists): cannot deserialize from Object value (no delegate- or property-based Creator)\n at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 3, column: 25]"}]}
I can't google it quickly
Share Improve this question asked Nov 21, 2024 at 11:53 HettHett 3,7632 gold badges38 silver badges56 bronze badges 1- hmm github.com/FasterXML/jackson-module-kotlin/issues/846 – Hett Commented Nov 21, 2024 at 12:00
1 Answer
Reset to default 0Rather a little late but I encountered the exact same behavior today (migrating from Jackson 2.17 to 2.18).
Was able, with some effort, to figure out the issue and a clean solution.
Jackson, not being able to find the constructor, is very clearly the root cause. And I'm inclined to believe the problem occurs in the specific scenario of multiple existing constructors.
The clean and very straightforward solution is to add the @JsonCreator annotation for each constructor Jackson will be using. Somehow it was decided this annotation is required as of 2.18 while it was not required before.
本文标签:
版权声明:本文标题:update fasterxml jackson from 2.17 to 2.18 lead error "no delegate- or property-based Creator" in kotlin - Sta 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736311170a1934644.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论