Spring配置文件没有自动提示解决

使用各种xml配置文件时,都需要添加相应的约束规则,有时候会出现不会自动提示,以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:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
        <!-- 配置组件扫描器 就是说明你的bean注解在哪个包下 -->
         <context:component-scan base-package="com.hk.spring.di01"></context:component-scan>
</beans>

添加了约束,却还没有绑定约束文件,所以没有提示,特别是在没有网络的情况下,从约束中可以看出约束文件的地址在http://www.springframework.org/schema/beans/spring-beans.xsd,还有一个在http://www.springframework.org/schema/context/spring-context.xsd,为了在没有网络的情况下也可以有提示,就需要绑定本地约束文件
先复制http://www.springframework.org/schema/context/spring-context.xsd这个地址
后续步骤如下Window—>Perferences—>MyEclips—>Files and Editors—>XML—>XML Files—>XML Catalog—>User Specified Entries—>Add

然后就会看到这个界面


然后,Key Type 选择URI,Key把你复制的内容粘贴进去,Location点击File System(绑定本地xsd)



然后找到对应的spring-context.xsd的位置,一般都是在你下载的Spring里



我的是4.2版本,根据自己的版本选择


点击ok,搞定,重新打开配置文件,提示就有了
这只是弄好了其中一个,另一个spring-beans.xsd也类似,只是它的本地位置不一样,其他操作一样

你可能感兴趣的:(spring)