myeclipse的代码模板设置

  1. 设置注释模板的入口: Window->Preference->Java->Code Style->Code Template 然后展开Comments节点就是所有需设置注释的元素啦。现就每一个元素逐一介绍:   
  2.   
  3.   
  4. 文件(Files)注释标签:   
  5.   
  6. /**     
  7. * @Title: ${file_name}   
  8. * @Package ${package_name}   
  9. * @Description: ${todo}(用一句话描述该文件做什么)   
  10. * @author A18ccms A18ccms_gmail_com     
  11. * @date ${date} ${time}   
  12. * @version V1.0     
  13. */   
  14.   
  15. 类型(Types)注释标签(类的注释):   
  16.   
  17. /**   
  18. * @ClassName: ${type_name}   
  19. * @Description: ${todo}(这里用一句话描述这个类的作用)   
  20. * @author A18ccms a18ccms_gmail_com   
  21. * @date ${date} ${time}   
  22. *   
  23. * ${tags}   
  24. */   
  25.   
  26. 字段(Fields)注释标签:   
  27.   
  28. /**   
  29. * @Fields ${field} : ${todo}(用一句话描述这个变量表示什么)   
  30. */   
  31. 构造函数标签:   
  32.   
  33. /**   
  34. <p>Title: </p>   
  35. <p>Description: </p>   
  36. * ${tags}   
  37. */   
  38.   
  39. 方法(Constructor & Methods)标签:   
  40.   
  41. /**   
  42. * @Title: ${enclosing_method}   
  43. * @Description: ${todo}(这里用一句话描述这个方法的作用)   
  44. * @param ${tags}    设定文件   
  45. * @return ${return_type}    返回类型   
  46. * @throws   
  47. */   
  48.   
  49. 覆盖方法(Overriding Methods)标签:   
  50.   
  51. /* (非 Javadoc)   
  52. <p>Title: ${enclosing_method}</p>   
  53. <p>Description: </p>   
  54. * ${tags}   
  55. * ${see_to_overridden}   
  56. */   
  57.   
  58. 代表方法(Delegate Methods)标签:   
  59.   
  60. /**   
  61. * ${tags}   
  62. * ${see_to_target}   
  63. */   
  64. getter方法标签:   
  65.   
  66. /**   
  67. * @return ${bare_field_name}   
  68. */   
  69.   
  70. setter方法标签:   
  71.   
  72. /**   
  73. * @param ${param} 要设置的 ${bare_field_name}   
  74. */   
  75. 例子:   
  76. <?xml version="1.0" encoding="UTF-8"?>   
  77. <templates>   
  78.     <template      
  79.                 autoinsert="false"      
  80.                 context="constructorcomment_context"      
  81.                 deleted="false"      
  82.                 description="Comment for created constructors"      
  83.                 enabled="true"      
  84.                 id="org.eclipse.jdt.ui.text.codetemplates.constructorcomment"   
  85.                 name="constructorcomment">   
  86.     /**     
  87.      * 创建一个新的实例 ${enclosing_type}.     
  88.      *     
  89.      * ${tags}     
  90.      */     
  91.     </template>   
  92.     <template      
  93.                 autoinsert="true"      
  94.                 context="settercomment_context"   
  95.                 deleted="false"      
  96.                 description="Comment for setter method"      
  97.                 enabled="true"      
  98.                 id="org.eclipse.jdt.ui.text.codetemplates.settercomment"      
  99.                 name="settercomment">   
  100.     /**     
  101.      * @param ${param} the ${bare_field_name} to set     
  102.      */     
  103.     </template>   
  104.     <template   
  105.                 autoinsert="false"      
  106.                 context="methodcomment_context"      
  107.                 deleted="false"      
  108.                 description="Comment for non-overriding methods"      
  109.                 enabled="true"      
  110.                 id="org.eclipse.jdt.ui.text.codetemplates.methodcomment"      
  111.                 name="methodcomment">   
  112.     /**     
  113.      * 此方法描述的是:     
  114.      * @author: wangxiongdx@163.com     
  115.      * @version: ${date} ${time}     
  116.      */     
  117.     </template>   
  118.     <template      
  119.                 autoinsert="true"      
  120.                 context="delegatecomment_context"      
  121.                 deleted="false"      
  122.                 description="Comment for delegate methods"      
  123.                 enabled="true"      
  124.                 id="org.eclipse.jdt.ui.text.codetemplates.delegatecomment"      
  125.                 name="delegatecomment">   
  126.     /**     
  127.      * ${tags}     
  128.      * ${see_to_target}     
  129.      */     
  130.     </template>   
  131.     <template   
  132.                 autoinsert="false"      
  133.                 context="filecomment_context"      
  134.                 deleted="false"      
  135.                 description="Comment for created Java files"      
  136.                 enabled="true"      
  137.                 id="org.eclipse.jdt.ui.text.codetemplates.filecomment"      
  138.                 name="filecomment">   
  139.     /**     
  140.      * 文件名:${file_name}     
  141.      *     
  142.      * 版本信息:     
  143.      * 日期:${date}     
  144.      * Copyright 足下 Corporation ${year}      
  145.      * 版权所有     
  146.      *     
  147.      */     
  148.     </template>   
  149.     <template      
  150.                 autoinsert="false"      
  151.                 context="gettercomment_context"      
  152.                 deleted="false"      
  153.                 description="Comment for getter method"      
  154.                 enabled="true"      
  155.                 id="org.eclipse.jdt.ui.text.codetemplates.gettercomment"      
  156.                 name="gettercomment">   
  157.     /**     
  158.      * ${bare_field_name}     
  159.      *     
  160.      * @return the ${bare_field_name}     
  161.      * @since   CodingExample Ver(编码范例查看) 1.0     
  162.     */     
  163.     </template>   
  164.     <template      
  165.                 autoinsert="true"      
  166.                 context="overridecomment_context"      
  167.                 deleted="false"      
  168.                 description="Comment for overriding methods"      
  169.                 enabled="true"      
  170.                 id="org.eclipse.jdt.ui.text.codetemplates.overridecomment"      
  171.                 name="overridecomment">   
  172.     /* (non-Javadoc)     
  173.      * ${see_to_overridden}     
  174.      */     
  175.     </template>   
  176.     <template      
  177.                 autoinsert="false"      
  178.                 context="fieldcomment_context"      
  179.                 deleted="false"      
  180.                 description="Comment for fields"      
  181.                 enabled="true"      
  182.                 id="org.eclipse.jdt.ui.text.codetemplates.fieldcomment"      
  183.                 name="fieldcomment">   
  184.     /**     
  185.      * ${field}:${todo}(用一句话描述这个变量表示什么)     
  186.      *     
  187.      * @since Ver 1.1     
  188.      */     
  189.     </template>   
  190.     <template      
  191.                 autoinsert="false"      
  192.                 context="typecomment_context"      
  193.                 deleted="false"      
  194.                 description="Comment for created types"      
  195.                 enabled="true"      
  196.                 id="org.eclipse.jdt.ui.text.codetemplates.typecomment"      
  197.                 name="typecomment">   
  198.     /**     
  199.      * 此类描述的是:     
  200.      * @author: wangxiongdx@163.com     
  201.      * @version: ${date} ${time}      
  202.      */     
  203.     </template>   
  204. </templates>   
  205. <?xml version="1.0" encoding="UTF-8"?>   
  206. <templates>   
  207.     <template   
  208.                 autoinsert="false"   
  209.                   context="constructorcomment_context"   
  210.                 deleted="false"   
  211.                 description="Comment for created constructors"   
  212.                 enabled="true"   
  213.                 id="org.eclipse.jdt.ui.text.codetemplates.constructorcomment"   
  214.                 name="constructorcomment">   
  215.     /**   
  216.      * 创建一个新的实例 ${enclosing_type}.   
  217.      *   
  218.      * ${tags}   
  219.      */   
  220.     </template>   
  221.     <template   
  222.                 autoinsert="true"   
  223.                 context="settercomment_context"   
  224.                 deleted="false"   
  225.                 description="Comment for setter method"   
  226.                 enabled="true"   
  227.                 id="org.eclipse.jdt.ui.text.codetemplates.settercomment"   
  228.                 name="settercomment">   
  229.     /**   
  230.      * @param ${param} the ${bare_field_name} to set   
  231.      */   
  232.     </template>   
  233.     <template   
  234.                 autoinsert="false"   
  235.                 context="methodcomment_context"   
  236.                 deleted="false"   
  237.                 description="Comment for non-overriding methods"   
  238.                 enabled="true"   
  239.                 id="org.eclipse.jdt.ui.text.codetemplates.methodcomment"   
  240.                 name="methodcomment">   
  241.     /**   
  242.      * 此方法描述的是:   
  243.      * @author: wangxiongdx@163.com   
  244.      * @version: ${date} ${time}   
  245.      */   
  246.     </template>   
  247.     <template   
  248.                 autoinsert="true"   
  249.                 context="delegatecomment_context"   
  250.                 deleted="false"   
  251.                 description="Comment for delegate methods"   
  252.                 enabled="true"   
  253.                 id="org.eclipse.jdt.ui.text.codetemplates.delegatecomment"   
  254.                 name="delegatecomment">   
  255.     /**   
  256.      * ${tags}   
  257.      * ${see_to_target}   
  258.      */   
  259.     </template>   
  260.     <template   
  261.                 autoinsert="false"   
  262.                 context="filecomment_context"   
  263.                 deleted="false"   
  264.                 description="Comment for created Java files"   
  265.                 enabled="true"   
  266.                 id="org.eclipse.jdt.ui.text.codetemplates.filecomment"   
  267.                 name="filecomment">   
  268.     /**   
  269.      * 文件名:${file_name}   
  270.      *   
  271.      * 版本信息:   
  272.      * 日期:${date}   
  273.      * Copyright 足下 Corporation ${year}   
  274.      * 版权所有   
  275.      *   
  276.      */   
  277.     </template>   
  278.     <template   
  279.                 autoinsert="false"   
  280.                 context="gettercomment_context"   
  281.                 deleted="false"   
  282.                 description="Comment for getter method"   
  283.                 enabled="true"   
  284.                 id="org.eclipse.jdt.ui.text.codetemplates.gettercomment"   
  285.                 name="gettercomment">   
  286.     /**   
  287.      * ${bare_field_name}   
  288.      *   
  289.      * @return the ${bare_field_name}   
  290.      * @since   CodingExample Ver(编码范例查看) 1.0   
  291.     */   
  292.     </template>   
  293.   
  294.     <template   
  295.                 autoinsert="true"   
  296.                 context="overridecomment_context"   
  297.                 deleted="false"   
  298.                 description="Comment for overriding methods"   
  299.                 enabled="true"   
  300.                 id="org.eclipse.jdt.ui.text.codetemplates.overridecomment"   
  301.                 name="overridecomment">   
  302.     /* (non-Javadoc)   
  303.      * ${see_to_overridden}   
  304.      */   
  305.     </template>   
  306.     <template   
  307.                 autoinsert="false"   
  308.                 context="fieldcomment_context"   
  309.                 deleted="false"   
  310.                 description="Comment for fields"   
  311.                 enabled="true"   
  312.                 id="org.eclipse.jdt.ui.text.codetemplates.fieldcomment"   
  313.                 name="fieldcomment">   
  314.     /**   
  315.      * ${field}:${todo}(用一句话描述这个变量表示什么)   
  316.      *   
  317.      * @since Ver 1.1   
  318.      */   
  319.     </template>   
  320.     <template   
  321.                 autoinsert="false"   
  322.                 context="typecomment_context"   
  323.                 deleted="false"   
  324.                 description="Comment for created types"   
  325.                 enabled="true"   
  326.                 id="org.eclipse.jdt.ui.text.codetemplates.typecomment"   
  327.                 name="typecomment">   
  328.     /**   
  329.      * 此类描述的是:   
  330.      * @author: wangxiongdx@163.com   
  331.      * @version: ${date} ${time}   
  332.      */   
  333.     </template>   
  334. </templates>   
  335.   
  336.   
  337. MyEclipse 6.5 代码提示的设置   
  338.   
  339. MyEclipse 选择 Windows ->Preperences ->General ->keys   
  340.   
  341. 找到 word completion的快捷键 把原alt+/删掉!//必须   
  342.   
  343. 把Content Assist 的快捷键 改成alt+/ 或者你想改的其他快捷键   
  344.   
  345.   
  346. MyEclipse编码设置   
  347.   
  348. Myeclipse安装后编码默认是GB18030,一般推荐用UTF-8。如果在导入项目后发现乱码现象,那是编码设置设置不对。   
  349.   
  350. 全局编码设置的方法:ToolBar-->Window-->Preferences-->General-->Workspace-->Text file encoding,设置合适的编码。   
  351.   
  352. 局部编码设置:在源码按右键-->General-->Editors-->Test Editors-->Spelling-->Encoding,这里是设置单个文件的编码。   
  353.   
  354. 推荐还是使用全局编码设置。   
  355.   
  356.   
  357. MyEclipse设置JSP页面默认编码方式:   
  358.   
  359. windows(窗口)-Preferences(首选项)-MyEclipse-Files & Editors-JSP-右侧encoding:设置为ISO10646/Unicode(UTF-8)   
  360.   
  361.   
  362. MyEclipse在Java文件中设置作者、日期等说明:   
  363.   
  364. windows(窗口)-Preferences(首选项)-Java-Code Style(代码样式)-Code Templates(代码模版)-右侧Comments(注释)-选择Types(类型)-点击edit(编辑)-输入如下信息   
  365.   
  366. /**   
  367. * @包名   ${package_name}   
  368. * @文件名 ${file_name}   
  369. * @作者   NoureWang   
  370. * @创建日期 ${date}   
  371. * @版本 V 1.0   
  372. */   
  373. 点击OK(确定)-选中左侧的代码样式-选择右侧复选框(Automatically add Comments for new Methods and types)(自动为新方法和类型添加注释)-点击Apply(应用)-点击OK(确定)   
  374.   
  375. eclipse里面有一个spell check的开关,把它关了。具体操作windows->preference->输入spell   
  376.   
  377. 自动提示:具体操作windows->preference->输入content assist    选择Java->editor->content assist   
  378.   
  379. Auto activation triggers for Java:后面输入.abcdefghijklmnopqrstuvwxyz 确定   
  380.   
  381. 然后导出   
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值