• Line 23 in XML document from class path resource [spring-mvc.xml] is invalid; nested exception is org.xml.sax.SAXParseException:


    今天在把自己的项目转为maven架构的时候,居然碰到了一个很奇葩的问题具体如下:

    org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:

      Line 23 in XML document from class path resource [spring-mvc.xml] is invalid; nested exception is 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.

    Caused by: 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.

     

    因为之前的applicationContext.xml编码问题,然后就以为是这个文档也是编码的问题。百度了很久,最后就差把这个xml文件手打了,依然报的这个错误,真真被弄得是焦头烂额了,编码问题,不太懂啊。

    然后,觉得是不是jar包导入的有问题(方向对了,但是我犯了个致命的错误),于是,把原来项目里的jar包重新导入到maven生成的war包中,再启动,依然是这个错误,要抓狂了都。

    其实,正确的方法应该是先把该项目总的jar包删除后,再从原项目导入jar包,这个是肯定不会出问题的。因为是用maven控制的包的导入,只能是在导入的时候出现了包冲突的问题,造成了解析错误,重新查看jar包引入的过程,在 这篇博文中发现,原来是在导入dbcp的jar包时,又引入了一个xml文档解析的jar包,造成了冲突。

    正确的引入dbcp依赖的方法是:

      排除依赖包

             <dependency>

                <groupId>commons-dbcp</groupId>
                <artifactId>commons-dbcp</artifactId>
                <version>1.2.1</version>
                <exclusions>
                    <exclusion>
                        <artifactId>xercesImpl</artifactId>
                        <groupId>xerces</groupId>
                    </exclusion>
                </exclusions>
            </dependency>

    大家共勉啊!!! 

     

     

  • 相关阅读:
    问题 A: 【递归入门】全排列
    第一个struct2程序(2)
    第一个struct2程序
    Java学习 第二节
    重学Java
    Servlet过滤器
    struct2
    Java web struct入门基础知识
    one by one 项目 part 6
    软件工程导论 桩模块和驱动模块
  • 原文地址:https://www.cnblogs.com/liuguobin/p/4155895.html
Copyright © 2020-2023  润新知