Eclipse 注釋模板設定

來源:互聯網
上載者:User

設定注釋模板的入口:

Window-<Preference-<Java-<CodeStyle-<Code Template 然後展開Comments節點就是所有需設定注釋的元素。現就每一個元素逐一介紹:

檔案(Files)注釋標籤:

 

/**  

 * Copyright ${year}公司名字. All rights reserved.

 *

 * @Title: ${file_name}

 * @Prject: ${project_name}

 * @Package: ${package_name}

 * @Description: ${todo}

 * @author: ${user}  

 * @date: ${date} ${time}

 * @version: V1.0  

 */

類型(Types)注釋標籤(類的注釋):

 

/**

 * @ClassName: ${type_name}

 * @Description: ${todo}

 * @author: ${user}

 * @date: ${date} ${time}

 * ${tags}

 */

欄位(Fields)注釋標籤:

 

/**

 * @fieldName: ${field}

 * @fieldType: ${field_type}

 * @Description: ${todo}

 */

建構函式標籤:

 

/**

 * @Title:${enclosing_type}

 * @Description:${todo}

 * ${tags}

 */

方法(Constructor & Methods)標籤:

 

/**

 * @Title: ${enclosing_method}

 * @Description: ${todo}

 * ${tags}

 * @return: ${return_type}

 */

覆蓋方法(Overriding Methods)標籤:

 

/* (non Javadoc)

 * @Title: ${enclosing_method}

 * @Description: ${todo}

 * ${tags}

 * ${see_to_overridden}

 */

代表方法(Delegate Methods)標籤:

 

/**

 * ${tags}

 * ${see_to_target}

 */

getter方法標籤:

 

/**

 * @return the ${bare_field_name}

 */

setter方法標籤:

 

/**

 * @param ${param} the ${bare_field_name} to set

 */

或者可以從網上下載配置好的.xml檔案匯入也可以。下載請點擊我!

 PS:在按照上面的方法設定後,一定要到windows->Preferences->general->Content Types,右側Context Types樹,點開Text,選擇Java Source File,在下面的Default encoding輸入框中輸入UTF-8,點Update,則設定Java檔案編碼為UTF-8,否則會出現字元編碼的問題。

經過如上的設定後,就可以使用快速鍵Alt+Shift+J來快速產生文檔的注釋了。使用方法如下:

檔案頭注釋:使用New->Class方法產生的檔案會在建立類的對話方塊選項中提示是否產生注釋,預設是選中的。這樣產生的.java檔案就有在檔案頭帶有上面設定的著作權資訊。若是使用New->File方法建立的java檔案則不會自動組建檔案頭的著作權資訊,必須手動輸入。方法、類、欄位等注釋:這一類的注釋只需要選中方法名、類名、或欄位名,然後使用Alt+Shift+J來自動產生注釋,然後補全資訊即可。


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.