2011-04-08 145 views

回答

37

@Documented是一個元註釋。在定義註釋時應用@Documented,以確保使用註釋的類在其生成的JavaDoc中顯示。我沒有看到太多的用處,但是there is an example here。先前的問題表明它是doesn't work automatically in Eclipse,但我已在Eclipse 3.6中進行了測試,並且我的註釋出現在JavaDoc彈出窗口中,而不管我是否將@Documented註釋附加到它們。

下面是從彈簧,這確保事務性方法標記爲這樣在JavaDoc一個例子:

​​3210
2

我發現了一個有用的頁面在Java Tutorials其給出的例子和更多的解釋了許多標準的註釋,其中包括使用@Documented。具體來說,請看底部的備註塊的前導示例(section Documentation)。

+0

鏈接現在已經死了 – 2013-05-15 14:45:04

+0

鏈接是固定的 – Sithsu 2013-07-20 16:06:55

23

如果我們的一些註解,說@InWork@Documented,則有@InWork每一個類,javadoc所產生的含有@InWork文本,對註釋的參考文本。

譯註:

@Documented 
@Inherited // for descenders of the annotation to have the @Documented feature automatically 
@Retention(RetentionPolicy.RUNTIME) // must be there 
public @interface InWork { 
    String value(); 
} 

註釋目標:

/** 
* Annotated class. 
*/ 
@InWork(value = "") 
public class MainApp {...} 

的Javadoc文本:

enter image description here

所以,你必須決定,如果註釋應顯示javadoc文本,如果是,則將@Documented設置爲i噸。

以上信息摘自Oracle documentation


請,通知,在Eclipse中,你會在Javadoc生成文本中看到所有的註解,是他們@Documented,還是不行。

4.3版本仍然正確。