Spring   发布时间:2022-04-09  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Spring Boot没有使用Jackson Kotlin插件大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

我不能强迫Spring为Jackson使用Kotlin模块.
问题是Jackson无法将JSON解析为数据类.

//Exception
2018-02-23 13:29:09.046 ERROR 24730 --- [nio-9300-exec-1] o.a.c.c.C.[.[.[.[dispatcherServlet]      : Servlet.service() for servlet [dispatcherServlet] in context with path [/services] threw exception [request processing Failed; nested exception is org.springframework.beans.beanInstantiationException: Failed to instantiate [*.model.User]: Constructor threw exception; nested exception is java.lang.IllegalArgumentexception: Parameter specified as non-null is null: method *.model.User.

我试图配置杰克逊,但它没有多大帮助.有什么奇怪的,在我配置ObjectMapper的@Bean方法中,一切正常.
此外,当我为非可空字段添加认值时,它们不会被覆盖.

@Configuration
class JacksonConfig {
    @Bean
    fun mappingJackson2httpmessageConverter(): MappingJackson2httpmessageConverter {
        val mapper = ObjectMapper().registerKotlinModule()
        mapper.configure(serializationFeature.FAIL_ON_EMPTY_BEANS,falsE)
        var user = mapper.readValue

可能重要的是模型与应用程序本身在不同的项目中.

Kotlin版本是1.20
杰克逊依赖:

    <><><>
本图文内容来源于网友网络收集整理提供,作为学习参使用,版权属于原作者。
@H_944_76@
@H_944_76@

大佬总结

以上是大佬教程为你收集整理的Spring Boot没有使用Jackson Kotlin插件全部内容,希望文章能够帮你解决Spring Boot没有使用Jackson Kotlin插件所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
猜你在找的Spring相关文章