讓Eclipse中spring的xml配置檔案出現屬性和類提示
在spring配置檔案中可以讓配置bean的時候出現提示,這裡需要做一些設定。設定包括安裝springide外掛,spring-beans-version.xsd檔案引入,增加xml編輯提示的字元,預設只有=>:。最後是讓配置檔案可以通過Spring Config Editor的方式開啟。
效果圖:1
效果圖:2
1、安裝spring ide外掛。
這裡需要選擇與自己eclipse對應的版本號,我這裡是(4.4.2),所以最後外掛地址是:http://dist.springsource.com/release/TOOLS/update/e4.4,輸入地址之後,回車,pending...完成之後選擇四個選項,分別是Core / Spring IDE、Extensions / Spring IDE、Integrations / Spring IDE、Resources / Spring IDE。最後一步一步,同意,Finish。
2、配置xml的catalog
將用到的spring-beans-RELEASE-VERSION.jar進行解壓,找到裡面的spring-beans-RELEASE-VERSION.xsd檔案,然後可以將它新增到使用者自定義xml catalog。並指定Key type為Schema location,以我的jar為例,key就是http://www.springframework.org/schema/beans/spring-beans-4.3.xsd。
3、增加xml編輯時的提示字元。
Window->Preferences->XML->XML Files->Editor->Content Assist,在Prompt when these characters are inserted:處新增.abc...
4、右鍵springxml配置檔案->Open With->Spring Config Editor
補充:
智慧提示,對於初學者很重要,可以不用盲敲,對熟練的研發來說也很重要,基本根據提示一眼就可以看出是哪一個,提升開發效率。另外直接使用Spring Tool Suite這個IDE,不用安裝外掛,不用配置xsd就可以實現編輯xml配置檔案出現自動提示。