2010-02-01 42 views
3

我真的很喜歡Eclipse爲我使用的各種Java庫類彈出Javadoc文檔的方式。但是,我也使用JPA和JAXB註釋,如@Entity和@XMLType。 Eclipse認識到這些是有效的,因爲我可以點擊ctrl-space並彈出。我還爲javax類獲得Javadoc。如何讓Eclipse爲javax註釋顯示Javadoc

但是這些註釋沒有Javadoc ......它只是報告說找不到Javadoc。

我已經下載了javadoc,將它安裝在我的系統上並與我的Java6系統庫(唯一安裝的)中的所有JAR相關聯。

任何想法?很難相信在註釋上沒有Javadoc!

+0

你弄明白了嗎? – Espen 2010-04-26 13:33:01

+1

我終於做到了。進入preferences-> maven並檢查工件源和工件javadoc。訣竅了。謝謝! – HDave 2010-04-29 04:27:39

回答

3

@Entity沒有標記@Documented註釋。

@Target(TYPE) 
@Retention(RUNTIME) 
public @interface Entity { 

如果用@ javax.Inject註釋嘗試相反,你應該看到的JavaDoc,因爲它打上@Documented。

@Target({ METHOD, CONSTRUCTOR, FIELD }) 
@Retention(RUNTIME) 
@Documented 
public @interface Inject {} 

的@Documented註解用的JavaDoc:

/** 
* Indicates that annotations with a type are to be documented by javadoc 
* and similar tools by default. This type should be used to annotate the 
* declarations of types whose annotations affect the use of annotated 
* elements by their clients. If a type declaration is annotated with 
* Documented, its annotations become part of the public API 
* of the annotated elements. 
* 
* @author Joshua Bloch 
* @version 1.6, 11/17/05 
* @since 1.5 
*/ 
@Documented 
@Retention(RetentionPolicy.RUNTIME) 
@Target(ElementType.ANNOTATION_TYPE) 
public @interface Documented { 
} 

一個解決辦法是導入Java源代替的JavaDoc。然後它會按照你的預期工作。