配置spring文件時候出現的小問題

Spring中的配置bean有兩種方式,今天做畢業設計的時候想使用註解的方式(簡單,方便)自動掃描裝配bean

大概是這樣的語句

<!-- 自動掃描與裝配bean -->

<context:component-scan base-package="cn.hlg.oa"></context:component-scan>

但是發現會出現一個錯誤

The prefix "context" for element "context:component-scan" is not bound.//大概意思就是這個東西無效,系統找不到。

對於上面這個錯誤的解決辦法是在<beans >中加上一句

xmlns:context=http://www.springframework.org/schema/context

這個還是很好找到的,可是下一步,我足足試了兩個多小時,就是這個錯誤解決之後,小紅叉並沒有消失,錯誤變成了

cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'context:component-scan'.

大概就是這個表情沒被引進去,解決辦法是在xsi:schemaLocation裏面加上兩句

http://www.springframework.org/schema/context

http://www.springframework.org/schema/context/spring-context-3.0.xsd

至此這個問題總算是解決了。

發佈了32 篇原創文章 · 獲贊 6 · 訪問量 1萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章