Javadoc 在 VSCode 中悬停时不显示
我目前正在使用 VSCode 开发一个 java 项目,当我将鼠标悬停在对象、类型或方法名称上时,文档不再显示。我不知道为什么或者我做了什么来改变这一点。
在下图中,我将鼠标悬停在第一次出现的 ByteBuyUtils 上,正如我们所看到的,没有显示任何内容。
这是在谷歌图片上找到的一张图片,显示了我悬停在某些东西上时想要得到的结果:
我正在使用 1.65.1 版本VSCode,在 Ubuntu 21.10 上。我使用的是 openjdk 版本“18-ea”2022-03-15。
我的 VSCode 上安装了以下扩展:
- Java 对 Java(TM) 的语言支持
- Red Hat Debugger for Java
- Test Runner for
I'm currently working on a java project using VSCode and when I hover an object, type or method name, documentation isn't showing anymore. I do not know why or what I did to change that.
In the following picture, I am hovering the first occurence of ByteBuyUtils, and as we can see, nothing is shown.
Here is a picture found on google pictures showing what I want to get when hovering something :
example of what I want when hovering code
I'm using 1.65.1 version of VSCode, on Ubuntu 21.10. I am using openjdk version "18-ea" 2022-03-15.
The following extensions are installed on my VSCode :
- Language Support for Java(TM) by Red Hat
- Debugger for Java
- Test Runner for Java
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以尝试几件事。
maven
如果您使用maven,则需要显式下载项目中包的javadoc和源代码。
mvn dependency:sources
mvn dependency:resolve -Dclassifier=javadoc
java home 属性
在 vscode 中,您需要设置 java home 属性。
Ctrl+Shift+p
打开命令面板用户设置 json
settings.json
java.lang. jdt.ls.java.home
并将值设置为 openjdk 包的根文件夹。对我来说,它是
/usr/lib/jvm/java-17-openjdk-amd64
。因此,我将其添加到
settings.json
中。要找到您的,请尝试
使用
ls -l
一直跟踪。/bin/java
部分之前的最后一个路径是您的JAVA_HOME
。安装 openjdk javadoc
您可以通过以下方式下载您的 openjdk 版本的
doc
: Ubuntu 上的 apt 。您应该会看到
openjdk-17-doc
和openjdk-17-source
可用。将17
更改为您选择的版本(例如18
)。然后最后
重启vscode
You may try a couple of things.
maven
If you are using maven, you need to explicitly download javadoc and source of the packages in your project.
mvn dependency:sources
mvn dependency:resolve -Dclassifier=javadoc
java home property
In vscode, you need to set java home property.
Ctrl+Shift+p
to open command paletteuser settings json
settings.json
should be openedjava.jdt.ls.java.home
and set the value to the root folder of your openjdk package.For me, it's
/usr/lib/jvm/java-17-openjdk-amd64
. So I addto the
settings.json
.To find yours, try
Trace all the way down with
ls -l
. The last path before the/bin/java
part is yourJAVA_HOME
.install openjdk javadoc
You can download the
doc
of your openjdk version via.apt
on Ubuntu.You should see
openjdk-17-doc
andopenjdk-17-source
available. Change17
to your version of choice (18
for example). ThenFinally
Restart vscode
我遇到了这个问题,并尝试了每个人的建议,将这个或那个编辑添加到设置中,但没有一个有任何效果。原来我需要安装openjdk源码包。对于 Ubuntu 上的 java 17,您可以在终端中运行以下命令:
I was having this problem, and tried everyone's suggestions of adding this or that edit to the settings and none of them had any effect. It turns out I needed to install the openjdk source package. For java 17 on Ubuntu, you'd run this in a terminal:
也许这就是您需要的扩展:Visual Studio IntelliCode
您还可以阅读这篇文章来了解Java需要的一些扩展:
https://code.visualstudio.com/docs/java/java-tutorial
Maybe this is the extension you need:Visual Studio IntelliCode
You can also read this article to see some of the extensions that Java needs:
https://code.visualstudio.com/docs/java/java-tutorial
按理说你下载的扩展有这个功能说明...为什么不安装一个智能提示扩展比如这个来尝试一下吗?或者请检查一下您是否关闭了设置:editor.hover.enabled(右下角搜索hover)?
It stands to reason that the extension you downloaded has this function to show that... why don't you install an intelligent prompt extension such as this oneto have a try? Or please check it out if you have turned off the setting:editor.hover.enabled(in the lower right corner and search for hover)?