日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > javascript >内容正文

javascript

【Spring心得】xmlns=“http://www.spring 和 xmlns:beans=“http://www.spring 差之毫厘谬以千里

發布時間:2024/1/18 javascript 50 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【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
  • xmlns="http://www.springframework.org/schema/beans"
  • 這個是正確的寫法,運行時不會出現異常

    ?錯誤代碼是下面這個:

    ????????applicationContext.xml

    <?xml version="1.0" encoding="UTF-8"?> <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:beans="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行,多了【:beans】

    ?出現問題的原因是,你在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 差之毫厘谬以千里的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。