我正在将一个Sping Boot Web服务从Kotlin1.4.32
升级到1.5.0
。
// Before:
kotlin("jvm") version "1.4.32"
kotlin("plugin.spring") version "1.4.32"
// After:
kotlin("jvm") version "1.5.0"
kotlin("plugin.spring") version "1.5.0"
升级并运行API后,出现以下错误:
com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `models.SeasonType` from String "Season": not one of the values accepted for Enum class: [NO_SEASON, UNKNOWN, SEASON]
SeasonType
是一个枚举类:
package models
import com.fasterxml.jackson.annotation.JsonCreator
enum class SeasonType(val value: String) {
SEASON("Season"),
NO_SEASON("NoSeason"),
UNKNOWN("Unknown");
companion object {
@JsonCreator
@JvmStatic
private fun creator(serializedValue: String): SeasonType =
values().firstOrNull { it.value == serializedValue } ?: UNKNOWN
}
}
为什么升级Kotlin后反序列化失败?
1条答案
按热度按时间3htmauhk1#
我能够通过升级到Kotlin
1.6.x
解决此问题。