如何让 Eclipse 显示 javax 注释的 Javadoc [英] How to get Eclipse to show Javadoc for javax annotations

查看:25
本文介绍了如何让 Eclipse 显示 javax 注释的 Javadoc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的很喜欢 Eclipse 为我使用的各种 Java 库类弹出 Javadoc 文档的方式.但是,我也使用 JPA 和 JAXB 注释,例如 @Entity 和 @XMLType.Eclipse 将这些识别为有效,因为我可以按 ctrl-space 并弹出它们.我还获得了 javax 类的 Javadoc.

I really like the way Eclipse has pop-up Javadoc documentation for the various Java library classes I use. However, I also use JPA and JAXB annotations such as @Entity and @XMLType. Eclipse recognises these as valid because I can hit ctrl-space and they pop-up. I also get Javadoc for javax classes.

但是没有这些注释的 Javadoc...它只是报告找不到 Javadoc.

But there is no Javadoc for these annotations...it just reports that Javadoc could not be found.

我已经下载了 javadoc,将其安装在我的系统上并与我的 Java6 系统库中的所有 JAR 相关联(唯一安装的).

I've downloaded the javadoc, installed it on my system and associated with all the JARs in my Java6 system library (the only one installed).

有什么想法吗?很难相信没有关于注释的 Javadoc!

Any ideas? Hard to believe there is no Javadoc on annotations!

推荐答案

@Entity 未使用 @Documented 批注标记.

@Entity isn't marked with the @Documented annotation.

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

如果您尝试使用 @javax.Inject 批注,您应该会看到 JavaDoc,因为它标有 @Documented.

If you try with the @javax.Inject annotation instead, you should see the JavaDoc, since it's marked with @Documented.

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

JavaDoc 中的@Documented 注解:

The @Documented annotation with 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.然后它会按您的预期工作.

A solution is to import the Java source instead of the JavaDoc. Then it will work as you expect.

这篇关于如何让 Eclipse 显示 javax 注释的 Javadoc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆