当 maxOccurs 大于 5000 时,jaxb2-maven-plugin 抛出异常

Dea*_*lze 3 maven jaxb2-maven-plugin

当我在旧版 xsd 上运行 jaxb2-maven-plugin 时,它会抛出此异常:

解析器的当前配置不允许将 maxOccurs 属性值设置为大于值 5,000

谷歌搜索此错误表明这是出于安全目的对 jaxp 施加的限制。可以在这样的代码中禁用它

SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING,false);
Run Code Online (Sandbox Code Playgroud)

但我需要在 Maven 中执行此操作。另外,xjc 有一个 -nv 开关来关闭此验证,这看起来是可行的方法。我无法更改 xsd。

在 jaxb2-maven-plugin 中传递 -nv 开关的语法是什么?

Dea*_*lze 7

我的同事 Vic Ganora 在 jaxb2-maven-plugin 的源代码中找到了答案。<plugin>...<configuration>在您需要添加的元素中

 <laxSchemaValidation>true</laxSchemaValidation>
Run Code Online (Sandbox Code Playgroud)