程序问答   发布时间:2022-06-01  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了为什么我得到 com.fasterxml.jackson.databind.exc.InvalidDefinitionException?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决为什么我得到 com.fasterxml.jackson.databind.exc.InvalidDefinitionException??

开发过程中遇到为什么我得到 com.fasterxml.jackson.databind.exc.InvalidDefinitionException?的问题如何解决?下面主要结合日常开发的经验,给出你关于为什么我得到 com.fasterxml.jackson.databind.exc.InvalidDefinitionException?的解决方法建议,希望对你解决为什么我得到 com.fasterxml.jackson.databind.exc.InvalidDefinitionException?有所启发或帮助;

我想将数据发送到服务器,但它收到此异常:com.fasterxml.jackson.databind.exc.InvalIDDeFinitionException:无法构造 retrofit2.Call 的实例(没有创建者,如默认构造,存在):抽象类型要么需要映射到具体类型,要么有自定义反序列化器,要么包含额外的类型信息 ,尽管如此,服务器给了我 http 200

我读了很多,但我无法解决这个问题

更新:当我在界面中使用 Call 时出现此错误

Object class:
data class CrmleadActivityAPIModel(
    @JsonProperty("oID")var oID: String = "",@JsonProperty("Subject") var subject: String? = null,@JsonProperty("StartOn") var startOn: Date = Date(),@JsonProperty("EndOn") var endOn: Date = Date(),@JsonProperty("Recurrence") var recurrence: Boolean = false,@JsonProperty("CrmOpportunityOID") var crmOpportunityOID: String = "",@JsonProperty("LOCATIOn") var LOCATIOn: String? = null,@JsonProperty("Description") var description: String? = null,@JsonProperty("SendNotificationtoparticipant") var sendNotificationtoparticipants: Boolean = false,@JsonProperty("SyncStatus") var syncStatus: Int? = null,)  {}

API:
    @POST("crm/saveActivitIEs")
    suspend fun sendCrmleadActivitIEs(@Body crmleadActivitIEs: List<CrmleadActivityAPIModel>) : Call<List<ResponseBody>>

Retrofit:


        var builder = OkhttpClIEnt.builder()
        builder = BuildTypeInitializations.setupInterceptor(builder)

        val objectMapper = ObjectMapper().registerModule(KotlinModule())
        objectMapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES,truE)
        val factory = JacksonConverterFactory.create(objectMapper)

        builder
            .addInterceptor(CustomresponseInterceptor(authAPI,prefManager))
            .readTimeout(1,TimeUnit.minutES)
            .writeTimeout(1,TimeUnit.minutES)
            .connectTimeout(1,TimeUnit.minutES)
            .retryOnConnectionFailure(true)

        return Retrofit.builder()
            .baseUrl(url)
            .addConverterFactory(factory)
            .clIEnt(builder.build())
            .build()
            .create(CrmAPI::class.java)





解决方法

我犯了一个错误,因为我同时使用了 suspend 关键字 az Call ,然后我删除了 suspend 关键字,错误消失了。

大佬总结

以上是大佬教程为你收集整理的为什么我得到 com.fasterxml.jackson.databind.exc.InvalidDefinitionException?全部内容,希望文章能够帮你解决为什么我得到 com.fasterxml.jackson.databind.exc.InvalidDefinitionException?所遇到的程序开发问题。

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

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