Why does JAXB need a no arg constructor for marshalling?

前端 未结 4 910
被撕碎了的回忆
被撕碎了的回忆 2020-12-04 18:02

If you try to marshal a class which references a complex type that does not have a no-arg constructor, such as:

import java.sql.Date;

@XmlRootElement(name =         


        
4条回答
  •  时光说笑
    2020-12-04 18:26

    Some enterprise and Dependency Injection frameworks use reflection Class.newInstance() to create a new instance of your classes. This method requires a public no-arg constructor to be able to instantiate the object.

提交回复
热议问题