没有使用Maven插件从xsd生成的JAXB类

时间:2012-11-14 11:02:32

标签: java maven maven-jaxb2-plugin jaxb2-maven-plugin

我无法看到使用jaxb2-maven-plugin从我的xsd生成的任何jaxb类

    <bulid>
    <pluginManagement>
    <plugins>
        <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>jaxb2-maven-plugin</artifactId>
        <version>1.5</version>
        <executions>
            <execution>
                <phase>generate-sources</phase>
                <goals>
                    <goal>generate</goal>
                </goals>
            </execution>
        </executions>
        <configuration>

            <schemaDirectory>src/main/xsd</schemaDirectory>
<sourceGenerationDirectory>target/sources</sourceGenerationDirectory>
<classGenerationDirectory>target/classes</classGenerationDirectory>
        </configuration>
        </plugin>
    </plugins>
    </pluginManagement>
    </bulid>
    <dependencies>
    <dependency>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>jaxb2-maven-plugin</artifactId>
        <version>1.5</version>
    </dependency>

我通过给予我的pom clean install generate:generate是一种正确的方法吗?请建议一种生成jaxb类的方法

我甚至试图通过mvn generate-sources运行没有生成任何东西

2 个答案:

答案 0 :(得分:1)

这在某个时间点对我有用;你可以在那里工作:

<plugin>
    <groupId>com.sun.tools.xjc.maven2</groupId>
    <artifactId>maven-jaxb-plugin</artifactId>
    <version>1.1</version>
    <executions>
        <execution>
            <goals>
                <goal>generate</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <removeOldOutput>false</removeOldOutput>
        <schemaDirectory>src/main/resources/xsd</schemaDirectory>
        <includeBindings>
            <includeBinding>*.xjb</includeBinding>
        </includeBindings>
    </configuration>
</plugin>

该插件已绑定到generate-sources阶段。

干杯,

答案 1 :(得分:1)

我刚刚将目标改为xjc和mvn jaxb2:xjc它工作了我能够获得生成的jxb类