囧,會想研究一下這東西的出發點,是因為我懶,以前新增新類別後,一些註解說明都是複製之前的類別內容,在來慢慢改,其中大部份的內容完全一模一樣,為了省下這一段工,以懶為出發點,就來研究如何客製化eclipse code template。

Step 1. 從eclipse menu 點擊 Window -> Preferences -> Java -> Code Style -> Code Templates


Step 2. 展開 Code 或 Comment ,選擇要修改的項目,在點擊 Edit 即可進行修改。


Note: 測試後發現 Comment 這部份怎麼修改都沒有反應。
最後我修改了 Code 中的兩個項目:
New java files(原始內容,其中filecomment, typecomment對應到Comment那部分,修改無效)
${filecomment}
${package_declaration}

${typecomment}
${type_declaration}


New java files(修改後,其中的log4j因為都會用到,懶到最高點,把它加進來)
${filecomment}
/*
* @(#)${file_name} ${date}
*
* Copyright (C) 2004 Your Company.
* All right reserved.
*/
${package_declaration}

import org.apache.log4j.Logger;

${typecomment}
/**
* 類別說明請新增
* @author ${user}
* @version 1.0 ${date}
*/
${type_declaration}


Class body(原本是空的,我加了log4j和Constructor)
/** for log4j */
static Logger log = Logger.getLogger(${type_name}.class.getName());

/** Constructor */
public ${type_name}() {}


經過這樣修改後,每次新增類別時,我又可以省打好多字 ^_______________^

arrow
arrow
    文章標籤
    Eclipse
    全站熱搜

    mark528 發表在 痞客邦 留言(0) 人氣()