简体   繁体   English

如何在VS Code中的java ant项目中导入外部jars

[英]How to import external jars in a java ant project in VS Code

I am editing a java project which uses ant to build.我正在编辑一个 java 项目,它使用 ant 来构建。

In one of my classes I import:在我的一门课中,我导入:

import org.slf4j.Logger;

import org.slf4j.LoggerFactory;

And get the error The import org.slf4j cannot be resolved并得到错误The import org.slf4j cannot be resolved

In other projects I would add the file to a /lib folder and to the referenced libraries under Java Projects, but when I attempt to copy a jar file into my java project with ant I still have the error.在其他项目中,我会将文件添加到 /lib 文件夹和 Java 项目下的引用库,但是当我尝试将 jar 文件复制到我的 java 项目和 ant 时,我仍然遇到错误。

The jar for slf4j is in a lib folder but the import statement still doesn't recognize it. slf4j 的 jar 在 lib 文件夹中,但 import 语句仍然无法识别它。 Is there a simple fix for this?有没有简单的解决方法?

Do I have to add the jar file somewhere else?我必须在其他地方添加 jar 文件吗?

Click the plus sign on the right side of Referenced Libraries under the JAVA PROJECTS panel to add a .jar package reference.单击JAVA PROJECTS面板下Referenced Libraries右侧的加号,添加.jar package 引用。

在此处输入图像描述

Dependency-management 依赖管理

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

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