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

时间:2019-03-14 12:39:21

标签: java maven xmlbeans wsdl2code xmlbeans-maven-plugin

我正在尝试为我拥有的某些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。

1 个答案:

答案 0 :(得分:1)

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