我們使用eclipse編輯spring配置文件時,經常沒有提示,而無從下手時. 現在我們就來解決沒有提示的問題.
原因是因爲eclipse中沒有配置xsd文件..
步驟一:把如下頭文件拷貝到你的spring配置文件中.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
</beans>
步驟二:根據頭文件的中的鏈接點擊去下載spring對應版本的.xsd文件 到本地..
步驟三:下載好之後,接下來就是要添加到eclipse中.
在eclipse菜單中進入
window->prefernces->XML->XML Catalog->Add ->File System,然後選擇剛纔下載下來的.xsd文件
location:比如C:\spring-beans-2.5.xsd
key type:選擇Schema Location
key:填寫http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
添加完成之後,重啓eclipse 看看是否有提示.. ..如果還沒有就多添加幾個版本的.xsd文件..試試。