Question

What is alternative to package-info.java which is used for JAXB. I don't want this class in project.What are alternative settings for jaxb to skip this?. Thank you.

Was it helpful?

Solution

Is not necessary indeed. You use it if you want to avoid jaxb to put something strange in your code like ns2 or whatever. If you don't like to see strange things in your xml you should put package-info.java in your packages to clearly define things: eg the namespace.

here's a clear example of what i mean Jaxb generated xml - problem with root element prefix

OTHER TIPS

In case you have been generating JaxB objects using xjc command. Using -npa option serves the purpose.

https://docs.oracle.com/javase/8/docs/technotes/tools/unix/xjc.html

This is also compatible with Java 11, when using the maven plugin cxf-xjc-plugin

Here is a sample to add arguments https://cxf.apache.org/cxf-xjc-plugin.html

<xsdOption>
    <xsd>${basedir}/.../yourXSD.xsd</xsd>
    <packagename>your.package.name</packagename>
    <extensionArgs>
        <extensionArg>-npa</extensionArg>
        <extensionArg>-no-header</extensionArg>
    </extensionArgs>
</xsdOption>

If you use no.nils.wsdl2java gradle plugin https://github.com/nilsmagnus/wsdl2java

You'd better add -xjc-npa option like that:

wsdl2java {
    ...
    wsdlsToGenerate = [
            [
                    '-xjc-npa',
                ...
            ]
    ]
}

A comprehensive list of options is here: https://docs.oracle.com/javase/8/docs/technotes/tools/unix/xjc.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top