没有为 XSD 和 WSDL 文件生成 XMLBean 类 (Maven)

No XMLBean Classes Generated for XSD and WSDL Files (Maven)

我想为我拥有的一些 XSD 和 WSDL 生成 XMLBean 类。我的 POM 文件如下所示:

<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>MySchemaFiles</groupId>
    <artifactId>MySchemaFiles</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>MySchemaFiles</name>
    <url>http://maven.apache.org</url>

    <dependencies>

        <!-- https://mvnrepository.com/artifact/org.apache.xmlbeans/xmlbeans -->
        <dependency>
            <groupId>org.apache.xmlbeans</groupId>
            <artifactId>xmlbeans</artifactId>
            <version>3.0.2</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.codehaus.mojo/xmlbeans-maven-plugin -->
        <dependency>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>xmlbeans-maven-plugin</artifactId>
            <version>2.3.3</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.apache.axis2/axis2-wsdl2code-maven-plugin -->
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-wsdl2code-maven-plugin</artifactId>
            <version>1.7.9</version>
        </dependency>

    </dependencies>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.target>1.8</maven.compiler.target>
        <maven.compiler.source>1.8</maven.compiler.source>
    </properties>

    <build>
        <pluginManagement>

            <plugins>

                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>xmlbeans-maven-plugin</artifactId>
                    <version>2.3.3</version>
                    <dependencies>
                        <!-- https://mvnrepository.com/artifact/org.codehaus.mojo/xmlbeans-maven-plugin -->
                        <dependency>
                            <groupId>org.codehaus.mojo</groupId>
                            <artifactId>xmlbeans-maven-plugin</artifactId>
                            <version>2.3.3</version>
                        </dependency>
                    </dependencies>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                        <schemaDirectory>${basedir}/src/main/resources/XSDFiles/</schemaDirectory>
                        <generatedSchemaDirectory>${basedir}/src/main/java/</generatedSchemaDirectory>
                        <outputJar>MySchemaFiles.jar</outputJar>
                        <classGenerationDirectory>${basedir}/target/java/classes/</classGenerationDirectory>
                        <verbose>true</verbose>
                        <sourceGenerationDirectory>${basedir}/src/main/java/</sourceGenerationDirectory>
                    </configuration>

                    <executions>

                        <execution>
                            <id>generate-sources</id>
                            <phase>generate-sources</phase>
                            <goals>
                                <goal>xmlbeans</goal>
                            </goals>
                            <configuration>
                                <quiet>false</quiet>
                                <staleFile>${basedir}/src/main/resources/target/staleFile/</staleFile>
                                <schemaDirectory>${basedir}/src/main/resources/XSDFiles/</schemaDirectory>
                                <sourceGenerationDirectory>${basedir}/src/main/java/</sourceGenerationDirectory>
                                <classGenerationDirectory>${basedir}/target/java/classes/</classGenerationDirectory>
                                <compiler>1.8</compiler>
                            </configuration>
                            <inherited>true</inherited>
                        </execution>

                    </executions>

                </plugin>

                <plugin>
                    <groupId>org.apache.axis2</groupId>
                    <artifactId>axis2-wsdl2code-maven-plugin</artifactId>
                    <version>1.7.9</version>
                    <dependencies>
                        <!-- https://mvnrepository.com/artifact/org.apache.axis2/axis2-wsdl2code-maven-plugin -->
                        <dependency>
                            <groupId>org.apache.axis2</groupId>
                            <artifactId>axis2-wsdl2code-maven-plugin</artifactId>
                            <version>1.7.9</version>
                        </dependency>
                    </dependencies>

                    <executions>

                        <execution>
                            <id>genrate-wsdl-to-java</id>
                            <phase>generate-sources</phase>
                            <goals>
                                <goal>wsdl2code</goal>
                            </goals>
                            <configuration>
                                <resources>
                                    <resource>
                                        <filtering>false</filtering>
                                        <directory>${basedir}/src/main/resources/WSDLFiles/</directory>
                                    </resource>
                                </resources>
                                <wsdlFile>${basedir}/src/main/resources/WSDLFiles/AtcProcessOrder.wsdl</wsdlFile>
                                <generateServerSide>false</generateServerSide>
                                <databindingName>xmlbeans</databindingName>
                                <outputDirectory>${basedir}/src/main/java/</outputDirectory>
                                <overWrite>true</overWrite>
                                <packageName>com.att.logicalprovisioning.atc.processorder</packageName>
                                <unpackClasses>true</unpackClasses>
                            </configuration>
                            <inherited>true</inherited>
                        </execution>

                    </executions>

                </plugin>

            </plugins>

        </pluginManagement>

    </build>

</project>

当我运行:

mvn clean package -X

我没有看到任何错误,或者至少没有任何东西引起我的注意,但是绝对没有生成 java 类。我试图弄清楚问题出在哪里,但由于缺少 examples/documentations 而无法弄清楚。我可以切换到 JAXB,但这不是一种选择。我必须坚持使用 XMLBeans。

您只配置了 <pluginManagement> 中的插件。您还需要在 <plugins> 部分(在 pluginManagement 之外)声明它们,以便它们成为您构建的一部分。