2
class AgentResponse[T] @JsonCreator()(@JsonProperty("result") val result: T, @JsonProperty("status") val status: ResponseStatus)
class ResponseStatus @JsonCreator()(@JsonProperty("succeeded") val succeeded: Boolean, @JsonProperty("message") val message: String, @JsonProperty("timeStamp") val timeStamp: Long)
new ObjectMapper().registerModule(DefaultScalaModule).writer().writeValue(out, new AgentResponse(result, new ResponseStatus(true, "OK", now)))
它拋出錯誤:如何使用Jackson對多參數構造函數序列化scala對象?
JsonMappingException: No serializer found for class com.fg.mail.smtp.rest.Handler$AgentResponse and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.SerializationFeature.FAIL_ON_EMPTY_BEANS))
斯卡拉對象如何看起來應該像爲它達到預期效果?
感謝Peter,您當場了。 – lisak
@Sloin請讓我知道它是否正常工作。我沒有時間去測試它。 –
是的,它現在按預期工作,謝謝 – lisak