如何在JAXB2 maven插件版本2.4中定义架构目录?

时间:2019-02-28 19:43:09

标签: java maven plugins pom.xml jaxb2-maven-plugin

我正在尝试在pom.xml中为我的架构定义目录。我不断收到一条错误消息:“此处不允许使用元素schemaDirectory”。我猜这个版本不支持此元素。那么如何在此版本中定义我的架构目录?

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>jaxb2-maven-plugin</artifactId>
    <version>2.4</version>
    <executions>
        <execution>
            <id>xjc</id>
            <goals>
                <goal>xjc</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <schemaDirectory>${project.basedir}src/main/resources</schemaDirectory>
        <outputDirectory>${project.basedir}src/main/java</outputDirectory>
    </configuration>
</plugin>

谢谢!

1 个答案:

答案 0 :(得分:0)

这对旧版本有效,例如。 1.5:

    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>jaxb2-maven-plugin</artifactId>
        <version>1.5</version>
        <executions>
            <execution>
                <id>xjc</id>
                <goals>
                    <goal>xjc</goal>
                </goals>
                <configuration>
                    <schemaDirectory>${project.basedir}src/main/resources</schemaDirectory>
                    <outputDirectory>${project.basedir}src/main/java</outputDirectory>
                </configuration>
            </execution>
        </executions>
    </plugin>

对于2.4版,根据文档,不再有schemaDirectory标签https://www.mojohaus.org/jaxb2-maven-plugin/Documentation/v2.4/xjc-mojo.html

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>jaxb2-maven-plugin</artifactId>
    <version>2.4</version>
    <executions>
        <execution>
            <id>xjc</id>
            <goals>
                <goal>xjc</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <outputDirectory>${project.basedir}src/main/java</outputDirectory>
        <sources>
            <source>${project.basedir}src/main/resources</source>
        </sources>
    </configuration>
</plugin>