Java Jackson反序列化程序未在webflux中与kotlin合作程序注册

Java Jackson反序列化程序未在webflux中与kotlin合作程序注册,java,spring,kotlin,jackson,spring-webflux,Java,Spring,Kotlin,Jackson,Spring Webflux,我对杰克逊的反序列化程序没有什么问题。 在类中添加注释时: @NotNull @JsonDeserialize(using = JsonPointDeserializer::class) val pharmLocation: Point, 它可以正确地反序列化。但我不想在代码中的任何地方添加它,因为我很懒,所以我在配置中添加了: @Bean fun jacksonCustomizer(): Jackson2ObjectMapperBuil

我对杰克逊的反序列化程序没有什么问题。 在类中添加注释时:

        @NotNull
        @JsonDeserialize(using = JsonPointDeserializer::class)
        val pharmLocation: Point,
它可以正确地反序列化。但我不想在代码中的任何地方添加它,因为我很懒,所以我在配置中添加了:

@Bean
    fun jacksonCustomizer(): Jackson2ObjectMapperBuilderCustomizer {
        return Jackson2ObjectMapperBuilderCustomizer { builder: Jackson2ObjectMapperBuilder ->
            builder
                    .serializerByType(Point::class.java, JsonPointSerializer())
                    .deserializerByType(Point::class.java, JsonPointDeserializer())
        }

    }
现在是有趣的一点。序列化程序工作正常,但反序列化程序工作不正常。我得到一个错误,来自请求的json看起来正确
“pharmLocation”:{“lat”:20.0,“lng”:20.0},
,但在堆栈上我看到:

org.springframework.core.codec.CodecException: Type definition error: [simple type, class org.springframework.data.geo.Point]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `org.springframework.data.geo.Point` (no Creators, like default constructor, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
 at [Source: (org.springframework.core.io.buffer.DefaultDataBuffer$DefaultDataBufferInputStream); line: 1, column: 74] (through reference chain: *.backend.advert.request.NewAdvert["pharmLocation"])```

我认为使用
waitbodyornull
可能是原因,但不知道如何处理它。

错误消息清楚地说明了问题所在,不是吗?您没有默认构造函数。您可以使用
@JsonCreator
来解决这个问题,但当我使用注释添加反序列化程序时,反序列化程序工作正常。我可以使用注释反序列化字段,但在bean中注册反序列化程序时不能。请显示
类好吗?我的点类是
import org.springframework.data.geo.Point
,反序列化程序代码:
类JsonPointDeserializer:JsonDeserializer(){override fun deserialize(p:JsonParser,ctxt:DeserializationContext?):点{val-jsonNode=p.codec.readTree(p)val x=jsonNode[“lat”].toString().toDouble()val y=jsonNode[“lng”].toString().toDouble()返回点(x,y)}
您是否也可以显示反序列化json的代码?或者这些是spring的内部代码?