mavenxml-serializationjaxbjaxb2

Generating automatically the jaxb.index file using maven


I have a package with multiple java classes inside.
I need to read xml files with the package's classes data.
Is there an automatic way (using maven) to generate the ObjectFactory class or the jaxb.index file from the content of the package?
I'm aware I can initiate the jaxb context with specific classes but this will force me to change the code each time I add a new class.
Thanks in advance,
Avner


Solution

  • You have to use the jaxb2-maven plugin to generate other things. If the classes have the appropriate annotations it shouldn't be a problem.

    <groupId>org.codehaus.mojo</groupId>
    <artifactId>jaxb2-maven-plugin</artifactId>
    <version>1.3.1</version>
    

    See here: http://mojo.codehaus.org/jaxb2-maven-plugin/