简体   繁体   English

VS Code Java 项目中没有“引用的库”

[英]No "referenced libraries" in VS Code Java project

I imported a Java project into Code that was originally developed in Eclipse.我将一个 Java 项目导入到 Code 中,该项目最初是在 Eclipse 中开发的。 At first, the entire "Java Projects" section in the explorer would not appear, but I did a "Clean Java language server workspace" and it appeared.起初,资源管理器中的整个“Java 项目”部分不会出现,但我做了一个“清理 Java 语言服务器工作区”,它就出现了。 However, "Referenced Libraries" does not appear:但是,“引用的库”没有出现:

在此处输入图像描述

I am not sure why this is the case.我不确定为什么会这样。 When I manually added the jars I wanted to the .classpath file, the "Referenced Libraries" appeared but said "Read-only."当我手动将 jars 添加到.classpath文件时,出现“引用库”但显示“只读”。 Further, doing a workspace clean removed these from the .classpath file, and the "Referenced Libraries" section disappeared again.此外,执行工作区清理从.classpath文件中删除了这些内容,并且“引用的库”部分再次消失了。 Am I missing something?我错过了什么吗? What can I do to get "Referenced Libraries" back?我该怎么做才能恢复“引用库”?

I had this problem and solved it editing the.classpath file directly.我遇到了这个问题并直接编辑.classpath文件解决了它。 After creating a "lib" directory aside "src" and "bin", I wrote a new line like this:在“src”和“bin”旁边创建一个“lib”目录后,我写了一个新行,如下所示:

<classpathentry kind="lib" path="lib/yourlibrary.jar">

After that, I opened VScode and it recognized the referenced library.之后,我打开 VScode 并识别出引用的库。

Remove.classpath and.project files from the project folder.从项目文件夹中删除 .classpath 和 .project 文件。 Then put your referenced library (for ex. jar file) file into lib folder.然后将您引用的库(例如 jar 文件)文件放入 lib 文件夹。 After you restart vscode it will be fixed.重新启动 vscode 后,它将被修复。

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

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