由於在xml文件中使用xml節點的提示信息,一般采用引入URL的方式,例如
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">
這種方式只能夠在網絡連接時才能夠使用,在網絡不穩定的情況下,智能提示效果很差,因此,通過設置Eclipse對Schema進行本地支持,可以解決上述問題。
下面本文以http://www.springframework.org/schema/context/spring-context-3.1.xsd為例進行設置:
第一步:選中Windows-->Preferences
第二步:尋找到下拉列表XML-->xml Category,點擊xml Category,右部區域出現一個新的界面
第三步:選中User Specified Entries,點擊Add按鈕,彈出一個對話框
第四步:尋找到xsd文件並選中,一般xsd文件放置在D:\EngineerSoftware\java_tool\spring-framework-3.2.0.RC2-dist\spring-framework-3.2.0.RC2\Schema文件下。
第五步:修改Key type下拉選項中Namespace name 為Schema location
第六步:Key 編輯框中在路徑后加入對應Schema的文件名。例如導入Schema文件后的路徑是http://www.springframework.org/schema/aop,在該路徑后加入\spring-aop-3.2.xsd,點擊OK,就完成了。
