jaxb2-maven-plugin不生成package-info.java

时间:2018-11-07 10:41:35

标签: java maven jaxb jaxb2-maven-plugin package-info

对于所有给定的XSD,jaxb2-maven-plugin均不会生成package-info.java文件。 (它仅生成类)。我们仍然使用Java 1.8

我的pom看起来像这样:

           <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxb2-maven-plugin</artifactId>
            <version>2.3.1</version>
            <configuration>
                <locale>en</locale>
                <outputDirectory>${project.build.directory}/generated-sources/jaxb</outputDirectory>
                <extension>true</extension>
                <encoding>UTF-8</encoding>
                <target>2.1</target>
                <verbose>false</verbose>
                <clearOutputDir>false</clearOutputDir>
                <extension>true</extension>
                <noGeneratedHeaderComments>true</noGeneratedHeaderComments>
                <generateEpisode>false</generateEpisode>
                <addGeneratedAnnotation>true</addGeneratedAnnotation>
                <xjbSources>
                    <xjbSource>res/bindings.xml</xjbSource>
                </xjbSources>
                <noPackageLevelAnnotations>false</noPackageLevelAnnotations>
            </configuration>
            <executions>
                <execution>
                    <id>services</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>xjc</goal>
                    </goals>
                    <configuration>
                        <packageName>common.input.services</packageName>
                        <sources>
                            <source>${project.basedir}/src/main/xsd/ServiceCatalogue.xsd</source>
                        </sources>
                    </configuration>
                </execution>
...

有什么想法吗?

1 个答案:

答案 0 :(得分:2)

您的ServiceCatalogue.xsd没有使用targetNamespace根元素中的xmlns<xsd>属性来声明目标名称空间。

例如:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
  xmlns="https://stackoverflow.com/ServiceCatalogue.xsd"
  targetNamespace="https://stackoverflow.com/ServiceCatalogue.xsd"
>
....
</xsd>