1

Java classes generated form xsd using the xjx plug don't seem to generate the default no args constructors.enter image description here

The Generated class is missing the default public NewStudent(){} constructor.enter image description here

Any idea how it can be achieved?

f1sh
  • 11,489
  • 3
  • 25
  • 51
Rabbani
  • 29
  • 1
  • 4
  • Why should it, as the default constructor on its own has no added value to your class? – Smutje Jan 27 '20 at 12:12
  • Every generated .class file should contain the default constructor automatically as long as there is no other constructor (which I did not see). I cannot imagine that xjc failted there. And you can do `new NewStudent()`. – Joop Eggen Jan 27 '20 at 12:12
  • There are no constructors in that class. That means the default constructor is implicitly present. – f1sh Jan 27 '20 at 12:13
  • @Smutje I am using a bean mapper plugin called dozer which requires the presence of the default constructor to instantiate classes on its own. so I need the default constructor – Rabbani Jan 27 '20 at 13:50
  • Yeah, but the default constructor is, as its name suggests, present by default. Just write `new NewStudent()` and compile it. – Smutje Jan 27 '20 at 13:51
  • @JoopEggen- the generated class files don't contain that. I just checked. Plus I can do NewStudent(), but this is just an example, I have an XSD with approx 30 classes with more to follow getting added up in the future. – Rabbani Jan 27 '20 at 13:53
  • You are aware that the default constructor is present as long as you don't have another, explicit constructor? – Smutje Jan 27 '20 at 14:00

0 Answers0