jaxb2-maven-plugin throws Exception when maxOccurs is greater than 5000

五迷三道 提交于 2019-12-11 09:56:09

问题


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

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

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);

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.

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


回答1:


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>.


来源:https://stackoverflow.com/questions/32610141/jaxb2-maven-plugin-throws-exception-when-maxoccurs-is-greater-than-5000

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!