SSM框架有时候会报下列错误
ERROR [http-bio-8083-exec-6] - Context initialization failed
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 18 in XML document from class path resource [springconfig.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'beans'.
情况一:内容溢出
这种情况只需要把tomcat启动内容增大即可,具体可以参考对应博客。
情况二:因版本问题容器装配失败
这种情况的特征是,在有网络的情况下启动不报错,运行页面正常 ,在断网的情况下启动也不报错,但是运行页面时就报错了
这种情况的原因可能是springconfig.xml的版本原因:
把springconfig.xml版本信息全去掉,修改为:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd"
default-lazy-init="true">
这时候在断网的情况下启动运行就不会报错了
总结:这个情况二是本人亲身经历的问题,一开始怀疑过版本问题,但还是去百度了,结果都是说内存溢出,把内存增大了发现问题还是没有解决,弄了挺久的,最后发现真的就是一开始认为的版本问题,其实只要联网这个问题也不会出现,但是某些项目是内网不能联网的就可能出现这样的问题,把这问题发出来,希望能帮到其他小白。