Spring的配置文件ApplicationContext.xml配置頭文件解析
spring中的applicationContext.xml配置頭文件解析
<?xmlversion="1.0"encoding="UTF-8"?>
<beansxmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.1.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.1.xsd
">
</beans>
首先要做的是導入相關jar包,這里一aop為例所以只說導入了aop相關的jar包
這四個jar包是必不可少的。
jar包下載地址:
http://pan.baidu.com/s/1nvTPNRV
配置頭文件所引用的文件包(版本號要匹配上)

步驟
(1)、下載spring-framework-4.1.6
(2)、eclipse中點擊window-preferances,在彈出框中輸入xml catalog,看到如下界面

點擊add
從文件選擇其中找到你所下載的spring-framework-4.16打開文件夾,然后打開schema文件夾
該目錄下就是你所要引入的相關標簽的文件夾
下面以aop標簽為例,其他標簽都是同樣的操作步驟。
(1)、打開aop文件夾。然后選中spring-aop-4.1.xsd,點擊打卡如圖
在這里需要特別注意的是location: F:\JavaIntegration\spring-framework-4.1.6.RELEASE-dist\spring-framework-4.1.6.RELEASE\schema\aop\spring-aop-4.1.xsd中的綠色背景的文字是與圖中綠色框中的一樣的,也就是版本一定要對應上,而紅色框中的值就是上圖中key的值。在這里特別說明的原因是有時我們會從網上復制頭文件不知道其中的原理這樣就會出現版本不對應的錯誤
注意!!!首先要保證 http://www.springframework.org/schema/beans/spring-beans.xsd 的約束文件Schema location要配置得有,不然其他的Schema location即使配置了也不會出來!!! 其次:key:的xsd文件最好不要寫版本號
到此aop的頭文件就配置完了,其他頭文件標簽配置與此類似。
