arcy arcy -4 years ago 88
Java Question

How does xjc determine the package to use for generated classes?

I have a project with an existing WSDL file from which it generates a number of Java classes corresponding to ComplexTypes. This has all been working fine for months, and still does. But I cannot figure out how it decides the package to use for the generated classes.

I now want to add another WSDL for a similar purpose, but its generated classes would go in a different package of course.

I have searched for "package" in all XML files; I have searched for the existing generated classes package name in all files (finding it only in the source files from which I use generated classes, which does tell me I spelled it correctly). The package name does not appear anywhere in the pom.xml that specifies the xjc plugin and goal.

It might work if I just tried it, but I'd much rather understand how it works and reduce the risk of littering some part of my workspace with generated classes. Where would XJC (or Maven, or whoever) be getting the package name?

Answer Source

It will combine the location of the xsd relative to the src folder and your namespace.

For example if you namespace is http://www.w3.org/2005/Atom your package will be org.w3._2005.atom.

It will add to this the package of the XSD.

You can override this, if you use the maven plugin you can specify , see http://www.mojohaus.org/jaxb2-maven-plugin/Documentation/v2.2/example_xjc_basic.html.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download