1

对于所有给定的 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>
...

有任何想法吗?

4

1 回答 1

2

ServiceCatalogue.xsd没有在根元素中使用targetNamespacexmlns属性声明目标命名空间。<xsd>

例如:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
  xmlns="https://stackoverflow.com/ServiceCatalogue.xsd"
  targetNamespace="https://stackoverflow.com/ServiceCatalogue.xsd"
>
....
</xsd>
于 2018-11-07T11:29:14.440 回答