當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
【Spring心得】xmlns=“http://www.spring 和 xmlns:beans=“http://www.spring 差之毫厘谬以千里
生活随笔
收集整理的這篇文章主要介紹了
【Spring心得】xmlns=“http://www.spring 和 xmlns:beans=“http://www.spring 差之毫厘谬以千里
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
運行java測試代碼時出現報錯,控制臺卡住了:
五月 03, 2018 9:11:10 下午 org.springframework.context.support.ClassPathXmlApplicationContext prepareRefresh 信息: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@ef4e59: startup date [Thu May 03 21:11:10 CST 2018]; root of context hierarchy 五月 03, 2018 9:11:10 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions 信息: Loading XML bean definitions from class path resource [applicationContext.xml]打開junit控制臺查看代碼如下:
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 5 in XML document from class path resource [applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 5; columnNumber: 2; cvc-elt.1: 找不到元素'beans' 的聲明。原因是你的xml配置文件頭里多了個【:beans】,具體分析如下:
?spring配置里面,正確的文件頭設置:
applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns="http://www.springframework.org/schema/beans"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd" > </beans>注意第3行,寫法是
applicationContext.xml這個是正確的寫法,運行時不會出現異常
?錯誤代碼是下面這個:
????????applicationContext.xml
?出現問題的原因是,你在namespace里面,取消了勾選beans,然后又勾選上了beans 雖然按照理論來說沒有錯誤,但是我測試MyEclipse和Eclipse均100%重現這個問題,而且肯定運行代碼報錯
?
————————————————————————————
2018.05.03????????????????????????????????
MedusaSTears??????????????????????????
Writen By? Windows Live Writer
總結
以上是生活随笔為你收集整理的【Spring心得】xmlns=“http://www.spring 和 xmlns:beans=“http://www.spring 差之毫厘谬以千里的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 李笑来投资iveryone 到底投资了什
- 下一篇: 京东电商增值服务模式