在Spring相應包導入正確的前提下,出現這個異常,是由於咱們在引入命名空間的時候,沒有正確引入它的DTD解析文件,以上面的context爲例,解決辦法以下:spring
在引入xml
xmlns:context="http://www.springframework.org/schema/context"
的同時,在xsi:schemaLocation這個字符串中添加context相關的解析文件:
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.2.xsd
如圖:
須要注意的是,因爲Spring版本的不一樣,圖中劃線的地方的數字可能會不一樣,我當前的是4.0,若是是其它版本,可能要換成其它數字(不寫數字也能夠)。blog