XML文件添加自动提示功能以及java文件中注释自动提示

来源:互联网 发布:交换机的数据帖转发式 编辑:程序博客网 时间:2024/05/17 00:56

一、 xml文件添加自动提示功能

xml文件的自动提示功能需要导入不同的相关xsd文件,下面以常用的beans及context来说明配置方法。

1.xml文件添加beans自动提示功能

Eclipse窗口选择

window – preferences – myeclipse – xml – xml catalog

选择User Specified Entries并点击add

 

Location:添加spring-beans-2.5.xsd文件所在路径  

Key type:选择Schema location

Key:自动填充后加上对应的xsd的名字,如/spring-beans-2.5xsd

 

确认后即有提示如图,

 

2. xml文件添加context自动提示功能

同理,

导入相关xsd文件

 

要想使用的话,还要在xml文件中加上下面几句话才行 

[java] view plain copy
 print?
  1. <pre name="code" class="javascript">xmlns:context="http://www.springframework.org/schema/context"  
  2.   
  3. http://www.springframework.org/schema/context  
  4.   
  5. http://www.springframework.org/schema/context/spring-context-2.5.xsd  
  6.   
  7. <context:annotation-config />  
  8. <span style="font-size:18px;"><strong><span style="color:#ff00;"></textarea></span></strong></span>  

如图,

 

二、java文件及注释自动提示

成功啦!一般的Java文件提示如图,

 

注释提示功能如图,

 

 

不过使用annotation注释功能也是要在xml配置文件中补充几句话的

用annotation必须加上四句话如下,

[java] view plain copy
 print?
  1. <pre name="code" class="html">xmlns:context="http://www.springframework.org/schema/context"            
  2.   
  3. http://www.springframework.org/schema/context   http://www.springframework.org/schema/context/spring-context-2.5.xsd  
  4.   
  5. <context:annotation-config />  


如图,

[java] view plain copy
 print?
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2.   
  3. <beans xmlns="http://www.springframework.org/schema/beans"  
  4.   
  5.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  6.   
  7.        xmlns:context="http://www.springframework.org/schema/context"  
  8.   
  9.        xmlns:aop="http://www.springframework.org/schema/aop"     
  10.        xsi:schemaLocation="http://www.springframework.org/schema/beans       
  11.        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd  
  12.   
  13.        http://www.springframework.org/schema/context     
  14.        http://www.springframework.org/schema/context/spring-context-2.5.xsd  
  15.        http://www.springframework.org/schema/aop          
  16.        http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">  
  17.   
  18. <context:annotation-config />  
  19.   
  20. <context:component-scan base-package="com.bjsxt"/>  
  21.   
  22.  <aop:aspectj-autoproxy />  

要使用不同的注释的前提也是已经导入过相应的jar包了,不同的注释要导入的包不同,举例来说,

@RequestMapping 对应spring-web-3.2.8.RELEASE.jar

@Aspect 对应aspectjweaver-1.6.9.jar和aspectjrt-1.6.9.jar

具体的版本好像是无所谓的,我选的时候就是找了本地库中版本最新的,似乎版本不一致也没有什么太大影响的



0 0
原创粉丝点击