尝试创建“Transacao”的实例时出现以下错误

`Error: Cannot construct br.com.cbmp.ecommerce.resposta.Transacao as it does not have a no-args constructor : Cannot construct br.com.cbmp.ecommerce.resposta.Transacao as it does not have a no-args constructor `

---- Debugging information ----

message : Cannot construct br.com.cbmp.ecommerce.resposta.Transacao as it does not have a no-args constructor

cause-exception : com.thoughtworks.xstream.converters.reflection.ObjectAccessException

cause-message : Cannot construct br.com.cbmp.ecommerce.resposta.Transacao as it does not have a no-args constructor `

class : br.com.cbmp.ecommerce.resposta.Transacao

required-type : br.com.cbmp.ecommerce.resposta.Transacao

path : /transacao

我知道XStream 1.3.1和JDK7有一个错误,但是我目前正在使用XStream 1.3.1和 JDK6 。任何想法为什么仍会发生此错误?

谢谢

最佳答案

3个解决方案:

  • 提供一个无参数的构造函数(显而易见)
  • 使该对象实现可序列化。
  • 升级到xstream 1.4.4 *

  • 我一直在使用解决方案2。

    *我验证了1.2.2不起作用,而1.4.4起作用了,还没有尝试过两者之间的任何版本

    关于java - Xstream No-args构造函数错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9621372/

    10-10 13:53