如何在 Eclipse 中查看 Spring Framework Javadoc?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18993503/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 13:10:29  来源:igfitidea点击:

How to view the Spring Framework Javadoc in Eclipse?

javaeclipsespringjavadoc

提问by user2813009

I have a folder full of HTML files that comprise the Spring Framework API documentation, http://docs.spring.io/spring/docs/3.2.4.RELEASE/javadoc-api/.

我有一个包含 Spring Framework API 文档http://docs.spring.io/spring/docs/3.2.4.RELEASE/javadoc-api/的 HTML 文件的文件夹。

What I'd like is to be able to hover over the name of a Spring method/interface/etc in Eclipse (like the ClassPathXmlApplicationContext class) and have the explanation appear from those documents. At the moment, what I get is "Note: This element neither has attached source nor attached Javadoc and hence no Javadoc could be found".

我想要的是能够将鼠标悬停在 Eclipse 中 Spring 方法/接口/等的名称上(如 ClassPathXmlApplicationContext 类),并从这些文档中显示解释。目前,我得到的是“注意:此元素既没有附加源代码也没有附加 Javadoc,因此找不到 Javadoc”。

Is there a way to tell Eclipse to implement that folder and its subfolders to make those Javadocs work? Do I have to package them in some way first? I'm using the Spring Tool Suite, or I can use regular Eclipse.

有没有办法告诉 Eclipse 实现该文件夹及其子文件夹以使这些 Javadoc 工作?我是否必须先以某种方式打包它们?我正在使用 Spring Tool Suite,或者我可以使用常规 Eclipse。

I've tried some things that were recommended in other answers, but I don't know what's going on.

我尝试了其他答案中推荐的一些东西,但我不知道发生了什么。

If anyone can help, that would be nice.

如果有人可以提供帮助,那就太好了。

采纳答案by Sotirios Delimanolis

Go to the properties of your project and select Java Build Path, then select the tab called Libraries, there you can expand any jar to select either Source attachmentor Javadoc locationand click the Editbutton. In the dialog that appears you can specify the folder, JAR or zip with the source code, or the location path or URL of the Javadoc.

转到项目的属性并选择Java Build Path,然后选择名为 的选项卡Libraries,在那里您可以展开任何 jar 以选择Source attachmentJavadoc location并单击Edit按钮。在出现的对话框中,您可以指定包含源代码的文件夹、JAR 或 zip,或者 Javadoc 的位置路径或 URL。

Hope this helps.

希望这可以帮助。

回答by Sotirios Delimanolis

If you want to learn a cool new technology, check out Maven. According to the site,

如果您想学习一项很酷的新技术,请查看Maven。据该网站称,

Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information.

Apache Maven 是一个软件项目管理和理解工具。基于项目对象模型 (POM) 的概念,Maven 可以从一条中央信息中管理项目的构建、报告和文档。

You can use it to add dependencies to your project. I won't go into that but when you do, Maven downloads if it is availablethe source code of those dependencies, typically the source and javadoc jars. You can then simply Open Declaration(F3) of the class you're interested in and check its source or javadoc. When you've downloaded the source code, the javadoc is also made available when hovering over a class, method, field, etc.

您可以使用它向项目添加依赖项。我不会去成,但是当你做什么,Maven的下载是否可用这些依赖的源代码,通常源和javadocjar秒。然后您可以简单地Open Declaration(F3) 您感兴趣的类并检查其源代码或 javadoc。下载源代码后,将鼠标悬停在类、方法、字段等上时也可以使用 javadoc。

回答by Ortomala Lokni

It's very easy.

这很容易。

You can simply right click on your project and go to Maven -> Download JavaDoc, you can also select Maven -> Download Sources

您只需右键单击您的项目并转到Maven -> Download JavaDoc,您也可以选择Maven -> Download Sources

If for whatever reasons this doesn't work you can also run :

如果由于某种原因这不起作用,您还可以运行:

mvn dependency:resolve -Dclassifier=javadoc

and then select Maven -> Update Project ...

然后选择 Maven -> Update Project ...