wsimport generates source code without parameterized constructors. Therefore, if the bean has many properties, one needs to invoke all the setters manually:
Person person = new Person();
person.setName("Alex");
Address address = new Address();
address.setCity("Rome");
person.setAddress(address);
It’s much more readable and convenient to just write the code like this:
Person person = new Person("Alex", new Address("Rome"))
So, is there any way to make wsimport do this job? (I’m using maven wsimport plugin)
Use the JAXB Value Constructor Plugin for the
xjctool.You can use it with maven-xjc-plugin like this: