简体   繁体   English

如何从java项目访问spark javadoc或源代码?

[英]how can I access spark javadoc or sources from java project?

I'm using Spark from a java project on IntelliJ 14 CE. 我在IntelliJ 14 CE上使用来自java项目的Spark。 Is there any way to navigate to the Spark sources or javadoc? 有没有办法导航到Spark源或javadoc? By default it only shows the rough decompile code without any comment. 默认情况下,它只显示粗略的反编译代码而没有任何注释。 I wouldn't mind navigating to the scala code if there was a way to do it. 如果有办法,我不介意导航到scala代码。 But maybe it would be better to plug in the javadoc, but I cannot find it anywhere 但也许插入javadoc会更好,但我无法在任何地方找到它

thanks 谢谢

What did the trick to me was to install the Scala plugin for IntelliJ, I was then able to navigate and debug through the spark core (which is written in scala), in spite of the project being in Java, and properly see the Javadoc, which was automatically inferred from the scala source code. 我的诀窍是为IntelliJ安装Scala插件,然后我能够通过spark核心(用scala编写)进行导航和调试,尽管项目是Java,并且正确地看到了Javadoc,这是从scala源代码自动推断出来的。 Of course, you also need to have the Spark source code properly setup, easy to do using Gradle or Maven. 当然,您还需要正确设置Spark源代码,使用Gradle或Maven很容易。

After discussion in the comments the solution appears to be to just add manually the JavaDoc to desired "Module" or Project. 在评论中讨论后,解决方案似乎只是手动将JavaDoc添加到所需的“模块”或项目。

The detailed answer is located at the following thread Attaching additional javadoc in Intellij IDEA 详细答案位于以下线程中在Intellij IDEA中附加其他javadoc

Then select the "Dependencies" tab, select the dependency that's missing the javadoc and click "Edit". 然后选择“Dependencies”选项卡,选择缺少javadoc的依赖项,然后单击“Edit”。 In the window that just showed up you see two buttons "Attach Javadoc" and "Specify Javadoc URL". 在刚出现的窗口中,您会看到两个按钮“Attach Javadoc”和“Specify Javadoc URL”。 If you have the javadoc in a jar file select the first one, if you want to point to a web site that contains the javadoc select the latest. 如果您在jar文件中有javadoc,请选择第一个,如果要指向包含javadoc的网站,请选择最新的。 That's it. 而已。

In your sbt build file you can always do this: 在您的sbt构建文件中,您始终可以执行以下操作:

"org.apache.spark" %% "spark-core" % versions('spark) withSources() withJavadoc(),
"org.apache.spark" %% "spark-sql" % versions('spark) withSources() withJavadoc(),

versions('spark) is just the version of spark that you are using. versions('spark)只是您正在使用的spark版本。

"right click on your pom.xml" -> "Maven" -> then choose "Download Sources and Documentation" “右键单击你的pom.xml” - >“Maven” - >然后选择“下载源代码和文档”

To avoid this in the future: "Preferences" -> "Build, Execution, Deployment" -> "Build Tools" -> "Maven" -> "Importing" -> Check the Automatically download Sources and Documentation boxes. 为了避免将来出现这种情况:“首选项” - >“构建,执行,部署” - >“构建工具” - >“Maven” - >“导入” - >选中自动下载源和文档框。

Credit to Yacov Schondorf and Stephen Boesch from Intellij user forums. 感谢来自Intellij用户论坛的Yacov Schondorf和Stephen Boesch。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM