Configure Target Packages in Binding Files - highsource/jaxb-tools GitHub Wiki
Configure Target Packages in Binding Files
The best way to specify the target package for your schema is to use a binding file.
To do this you normally (i.e. in the default cofiguration) create a file named *.xjb in the directory src/main/resources. You can associate the target package with the schema using an SCD binding via namespace:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<jaxb:bindings
	version="2.1"
	xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
	xmlns:xs="http://www.w3.org/2001/XMLSchema">
	<jaxb:bindings scd="x-schema::a" xmlns:a="urn:a">
		<jaxb:schemaBindings>
			<jaxb:package name="org.ab.a"/>
		</jaxb:schemaBindings>		
	</jaxb:bindings>
</jaxb:bindings>
Alternatively you can use schemalocation and XPath binding:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<jaxb:bindings
	version="2.1"
	xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
	xmlns:xs="http://www.w3.org/2001/XMLSchema">
	<jaxb:bindings schemaLocation="a.xsd" node="//xs:schema">
		<jaxb:schemaBindings>
			<jaxb:package name="org.ab.a"/>
		</jaxb:schemaBindings>
	</jaxb:bindings>
</jaxb:bindings>
It is explicitly not recommended to use the generatePackage configuration element as it configures target package for the whole model. This makes namespace-package mapping very problematic. Please use binding files instead.