当maxOccurs大于5000时,jaxb2-maven-plugin引发异常 [英] jaxb2-maven-plugin throws Exception when maxOccurs is greater than 5000

查看:223
本文介绍了当maxOccurs大于5000时,jaxb2-maven-plugin引发异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

When I run the jaxb2-maven-plugin on a legacy xsd it throws this Exception:

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

Current configuration of the parser doesn't allow a maxOccurs attribute value to be set greater than the value 5,000

搜索该错误表明,出于安全目的,这是对jaxp施加的限制.可以在这样的代码中将其禁用

Googling this error shows that this is a limit that was put on jaxp for security purposes. It can be disabled in code like this

SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING,false);

但是我需要在Maven中执行此操作.同样,xjc具有-nv开关以关闭此验证,这看起来很可行.我无法更改xsd.

but I need to do this in maven. Also, xjc has a -nv switch to turn off this validation and that looks like the way to go. I can't change the xsd.

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

What's the syntax for passing the -nv switch in the jaxb2-maven-plugin?

推荐答案

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

My colleague Vic Ganora found the answer in the source code for the jaxb2-maven-plugin. In the <plugin>...<configuration> element you need to add

 <laxSchemaValidation>true</laxSchemaValidation>.

这篇关于当maxOccurs大于5000时,jaxb2-maven-plugin引发异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆