Spring写配置文件时不提示怎么办?

想要编写xml文件时代码提示,其实只要配置了相应的xsd文件即可,xsd文件也就是xml文件的一个约束。就是决定了你xml文件中可以写哪些东西。

xsd文件是xml文件的元数据文件。


以bean标签为例:

你编写<bean>标签的时候没有提示,则可以配置pring-beans-3.0.xsd这个文件到xml头信息中

直接在spring压缩包中找到相应的xsd文件,在eclipse中配置下即可。

配置方式:


上图key的值应该和

<?xml version="1.0" encoding="UTF-8"?>

这个文件中的http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  一样 

但是我怎么知道这个key该填写什么路径呢?

分析这个链接:http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 

浏览器中打开:http://www.springframework.org/schema/ 

出现如下界面


假如你想配置bean的提示,那就点击beans链接


点击选择相应的版本。

点击了之后地址栏的地址为:http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 

页面上打印的信息也就是spring-beans-3.0.xsd文件的内容



总结:

1、在eclipse的XML catalog中配置相应的xsd文件

2、在xml文件的头信息中配置相应的key,这样在编写xml文件的时候就可以去读取xsd文件,来约束当前xml文件中可以写哪些内容

  http://www.springframework.org/schema/beans

  http://www.springframework.org/schema/beans/spring-beans-3.0.xsd


spring2.5和spring3.0各个不同的版本,其xsd文件位置也不同。

spring2.5 xsd文件位置:在src源代码相应模块的config目录下

..spring-framework-2.5.6srcorgspringframeworkaopconfigspring-aop-2.5.xsd

spring3.0 xsd文件位置:由于spring3.0之后的版本是按各个模块来分包的,所以在其projects目录中

..spring-framework-3.0.0.RELEASEprojectsorg.springframework.aopsrcmain esourcesorgspringframeworkaopconfigspring-aop-3.0.xsd







原文地址:https://www.cnblogs.com/meet/p/4748373.html