You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在pom.xml中配置jaxb2-maven-plugin指定schemagen输入类

实现方案

直接在schemagen的执行配置下增加includes参数,显式声明要处理的类路径即可。插件默认会全量扫描所有编译类,指定includes后只会处理命中规则的文件,其余包的类会被自动忽略。

修改完成的插件配置如下:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>jaxb2-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>schemagen</id>
            <goals><goal>schemagen</goal></goals>
            <configuration>
                <includes>
                    <include>com/example/entities/**/*.java</include>
                    <include>com/example/model/**/*.java</include>
                </includes>
            </configuration>
        </execution>
    </executions>
</plugin>

注意点

  • 路径必须用斜杠/分隔包层级,不能使用包名常用的点.分隔,否则规则匹配不生效
  • 规则末尾的**/*.java表示匹配对应包及其所有子包下的Java类,如果不需要处理子包,把**/去掉即可
  • 配置要放在<execution>节点下的<configuration>里,不要错放到插件根节点的configuration层级,避免影响插件其他goal的执行

内容的提问来源于stack exchange,提问作者Nice Books

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.30 09:09:20