0

我正在尝试为我拥有的一些 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 类。我试图找出问题所在,但由于缺乏示例/文档而无法解决。我可以切换到 JAXB,但这不是一个选项。我必须坚持使用 XMLBeans。

4

1 回答 1

1

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

于 2019-03-14T13:02:47.613 回答