maven-jaxb2-plugin:如何在pom.xml中完成这个xjc命令行?
由于需要编译XSD的各种问题(在其他SO文章中描述),我有一个绑定文件和一个本地扩展模式。下面的命令行工作正常,但我很难找到正确的maven-jaxb2-plugin:如何在pom.xml中完成这个xjc命令行?,maven,jaxb,xjc,maven-jaxb2-plugin,Maven,Jaxb,Xjc,Maven Jaxb2 Plugin,由于需要编译XSD的各种问题(在其他SO文章中描述),我有一个绑定文件和一个本地扩展模式。下面的命令行工作正常,但我很难找到正确的pom.xml配置来模拟这一点: xjc -nv src/main/resources/TCIP_4_0_0_Final.xsd src/main/resources/local/ObaCcLocationReport.xsd -b src/main/resources/local/rename.xjb -d target 主要是,如何指定多个XSD?我试过: &l
pom.xml
配置来模拟这一点:
xjc -nv src/main/resources/TCIP_4_0_0_Final.xsd src/main/resources/local/ObaCcLocationReport.xsd -b src/main/resources/local/rename.xjb -d target
主要是,如何指定多个XSD?我试过:
<schemaDirectory>src/main/resources</schemaDirectory>
<schemaIncludes>
<include>TCIP_4_0_0_Final.xsd</include>
<include>local/ObaCcLocationReport.xsd</include>
</schemaIncludes>
没有成功。建议
编辑
这是一个解决办法,但并不理想:
由于obaclocationreport.xsd
依赖于作为TCIP_4_0_0_Final.xsd
一部分编译的模式,因此我只需确保它在编译之后得到编译,并且它似乎按照文件路径顺序处理文件。因此,我将obaclocationreport.xsd
放入x
子文件夹,并将pom.xml
更改为:
<schemaDirectory>src/main/resources</schemaDirectory>
<schemaIncludes>
<include>TCIP_4_0_0_Final.xsd</include>
<include>x/ObaCcLocationReport.xsd</include>
</schemaIncludes>
src/main/resources
TCIP_4_0_0_Final.xsd
x/obacclositionreport.xsd
这就正确地编译了模式并生成了Java文件。免责声明:我是本文的作者 那么编译取决于XJC命令中模式文件的顺序?嗯,很有趣。为什么? 在这种情况下,请发布
mvn-xclean生成源代码log
Maven似乎并没有像我得到的那样维护文件模式的顺序:
schemas=[file:/.../src/main/resources/local/ObaCcLocationReport.xsd,
file:/.../src/main/resources/TCIP_4_0_0_Final.xsd]
这不是你想要的。请把它修好。(我依赖于这里的一个Maven库,但可以用不同的方法来维持秩序。)
您可以按如下方式对其进行配置:
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<executions>
<execution>
<id>generate</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<strict>false</strict>
<schemaIncludes/>
<schemas>
<schema>
<fileset>
<includes>
<include>TCIP_4_0_0_Final.xsd</include>
</includes>
</fileset>
</schema>
<schema>
<fileset>
<includes>
<include>local/ObaCcLocationReport.xsd</include>
</includes>
</fileset>
</schema>
</schemas>
</configuration>
</execution>
</executions>
</plugin>
注:
- 不要忘记
,否则默认情况下将包括src/main/resources/*.xsd
false
为您提供-nv
- 您始终可以使用
args
/arg
在较低级别上配置xjc
,但我不推荐这样做
免责声明:我是本文的作者
那么编译取决于XJC命令中模式文件的顺序?嗯,很有趣。为什么?
在这种情况下,请发布mvn-xclean生成源代码log
Maven似乎并没有像我得到的那样维护文件模式的顺序:
schemas=[file:/.../src/main/resources/local/ObaCcLocationReport.xsd,
file:/.../src/main/resources/TCIP_4_0_0_Final.xsd]
这不是你想要的。请把它修好。(我依赖于这里的一个Maven库,但可以用不同的方法来维持秩序。)
您可以按如下方式对其进行配置:
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<executions>
<execution>
<id>generate</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<strict>false</strict>
<schemaIncludes/>
<schemas>
<schema>
<fileset>
<includes>
<include>TCIP_4_0_0_Final.xsd</include>
</includes>
</fileset>
</schema>
<schema>
<fileset>
<includes>
<include>local/ObaCcLocationReport.xsd</include>
</includes>
</fileset>
</schema>
</schemas>
</configuration>
</execution>
</executions>
</plugin>
注:
- 不要忘记
,否则默认情况下将包括src/main/resources/*.xsd
false
为您提供-nv
- 您始终可以使用
args
/arg
在较低级别上配置xjc
,但我不推荐这样做
免责声明:我是本文的作者
那么编译取决于XJC命令中模式文件的顺序?嗯,很有趣。为什么?
在这种情况下,请发布mvn-xclean生成源代码log
Maven似乎并没有像我得到的那样维护文件模式的顺序:
schemas=[file:/.../src/main/resources/local/ObaCcLocationReport.xsd,
file:/.../src/main/resources/TCIP_4_0_0_Final.xsd]
这不是你想要的。请把它修好。(我依赖于这里的一个Maven库,但可以用不同的方法来维持秩序。)
您可以按如下方式对其进行配置:
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<executions>
<execution>
<id>generate</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<strict>false</strict>
<schemaIncludes/>
<schemas>
<schema>
<fileset>
<includes>
<include>TCIP_4_0_0_Final.xsd</include>
</includes>
</fileset>
</schema>
<schema>
<fileset>
<includes>
<include>local/ObaCcLocationReport.xsd</include>
</includes>
</fileset>
</schema>
</schemas>
</configuration>
</execution>
</executions>
</plugin>
注:
- 不要忘记
,否则默认情况下将包括src/main/resources/*.xsd
false
为您提供-nv
- 您始终可以使用
args
/arg
在较低级别上配置xjc
,但我不推荐这样做
免责声明:我是本文的作者
那么编译取决于XJC命令中模式文件的顺序?嗯,很有趣。为什么?
在这种情况下,请发布mvn-xclean生成源代码log
Maven似乎并没有像我得到的那样维护文件模式的顺序:
schemas=[file:/.../src/main/resources/local/ObaCcLocationReport.xsd,
file:/.../src/main/resources/TCIP_4_0_0_Final.xsd]
这不是你想要的。请把它修好。(我依赖于这里的一个Maven库,但可以用不同的方法来维持秩序。)
您可以按如下方式对其进行配置:
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<executions>
<execution>
<id>generate</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<strict>false</strict>
<schemaIncludes/>
<schemas>
<schema>
<fileset>
<includes>
<include>TCIP_4_0_0_Final.xsd</include>
</includes>
</fileset>
</schema>
<schema>
<fileset>
<includes>
<include>local/ObaCcLocationReport.xsd</include>
</includes>
</fileset>
</schema>
</schemas>
</configuration>
</execution>
</executions>
</plugin>
注:
- 不要忘记
,否则默认情况下将包括src/main/resources/*.xsd
false
为您提供-nv
- 您始终可以使用
args
/arg
在较低级别上配置xjc
,但我不推荐这样做
不,对不起,我不清楚:它似乎是按文件系统顺序处理它们,而忽略了它们在pom.xml
中的显示顺序。我将尝试完全独立的
元素,谢谢。不,对不起,我不清楚:它似乎是按文件系统顺序处理它们,而忽略了它们在pom.xml
中的显示顺序。我将尝试完全独立的
元素,谢谢。不,对不起,我不清楚:它似乎是按文件系统顺序处理它们,而忽略了它们在pom.xml
中的显示顺序。我将尝试完全独立的
元素,谢谢。不,对不起,我不清楚:它似乎是按文件系统顺序处理它们,而忽略了它们在pom.xml
中的显示顺序。我将尝试完全独立的
元素,谢谢。