An ''all'' model group must appear in a particle with...问题解决记录
场景:
最近在一个新项目的依赖包调整过程中,引入包之后,发现项目启动报错,一直启动不成功,经过查询和排查,发现是包对xml解析冲突的问题;
报错信息:
[WARNING] Nested in org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 24 in XML document from URL [file:xxxxxxx/target/classes/web-servlet.xml] is invalid; nested exception is org.xml.sax.SAXParseException; systemId: http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd; lineNumber: 24; columnNumber: 20; cos-all-limited.1.2: An ''all'' model group must appear in a particle with '{'min occurs'}'='{'max occurs'}'=1, and that particle must be part of a pair which constitutes the '{'content type'}' of a complex type definition.: org.xml.sax.SAXParseException: cos-all-limited.1.2: An ''all'' model group must appear in a particle with '{'min occurs'}'='{'max occurs'}'=1, and that particle must be part of a pair which constitutes the '{'content type'}' of a complex type definition. at org.apache.xerces.parsers.DOMParser.parse (DOMParser.java:267) at org.apache.xerces.jaxp.DocumentBuilderImpl.parse (DocumentBuilderImpl.java:201) at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument (DefaultDocumentLoader.java:76) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadDocument (XmlBeanDefinitionReader.java:429) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions (XmlBeanDefinitionReader.java:391) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions (XmlBeanDefinitionReader.java:336) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions (XmlBeanDefinitionReader.java:304) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions (AbstractBeanDefinitionReader.java:181)
排查步骤:
1. 是不是报错信息中的xml写错了配置;
2. 包冲突, 从错误堆栈中可以看到 xerces 包的DOMParser,猜测是 xerces 和 Spring的对于xml的解析出现了冲突,然后将xerces包中项目中排除(包括直接依赖和传递依赖)
结果:
发现是包冲突了,去掉common-pool的传递依赖的xerces包,问题解决。
时间的长河会慢慢告诉你生命的真谛