记一次org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException异常解决方法

今天在做一个SSM的shiro的demo,在SpringMVC的配置文件里频繁报错  :

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 13 in XML document from class path resource [applicationContext-shiro.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 13; columnNumber: 63; cvc-elt.1: 找不到元素 'beans' 的声明。

java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext

过程:

试过很多网上的解决方法都不行,Spring就是加载不了bean,磨了很久还是不能解决,本来准备放弃了,偶然看到Spring bean的一个属性default-lazy-init="true",和关于xsd解析文件版本号,把本来是4.0的版本号改成3.0项目就能正常启动了。

解决方法:

1.在配置xsd解析文件bean上加属性default-lazy-init="true"

2.还有一种可能就是xsd解析文件版本号有问题,无法获取xsd文件,你可以从网上下xsd文件jar包到本地lib,或是修改版本号,这里我把4.0版本号改成3.0即可解决问题。

猜你喜欢

转载自blog.csdn.net/qq_41737716/article/details/81624157
今日推荐