3

我接管了一个使用maven-jaxb2-plugin的 Java 项目的所有权。一切都编译得很好,但是,它没有将 xsd 文件放入生成的 .jar 文件中。

我能想到的唯一不同的是我的 .xsd 文件曾经存在于文件夹src/main/resources中,现在它们位于一个名为xsd的文件夹中。

src/main/resources文件夹是maven(或 jaxb?)在打包 .jar 文件时查找内容的默认文件夹名称吗?如果是这样,我该如何添加/更改默认值?

这是我的 jaxb 插件配置:

<build>
    <plugins>
        <plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <configuration>
                <catalog>xsd/catalog.xml</catalog>
                <catalogResolver>org.jvnet.jaxb2.maven2.resolver.tools.ClasspathCatalogResolver</catalogResolver>
                <extension>true</extension>
                <schemaDirectory>${basedir}/xsd</schemaDirectory>
                <schemaIncludes>
                    <include>core-types.xsd</include>
                </schemaIncludes>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

谢谢你。

4

1 回答 1

2

是的,“src/main/resources”数据默认包含在 jar 中。

You can add other resources following the example here (first hit on google for "maven resources folder").

于 2013-01-17T20:59:23.500 回答