如何在 VS Code 中为简单的 Java 项目(即没有任何构建工具的非托管文件夹)添加 Maven 依赖项?

How do I add a Maven dependency in VS Code for a simple Java project (i.e. an unmanaged folder without any build tools)?

我正在尝试为 Mario-AI-Framework using the Deep Java Library (DJL). I'm using VS Code with the Java extension, as this is part of a larger project, mainly in Python. Now I have a Pytorch model trained and ready to go but I need the DJL Pytorch engine to load it in Java. The problem is, the only info I can find on how to import this thing uses Maven or they build it from source using Gradle 构建一个 AI 模型。我不习惯使用 Java 项目和导入库,所以我完全迷失在这里。如果有人能指出我正确的方向,我将不胜感激。

您始终可以下载存储在 Maven 存储库中的 jar 文件并手动将它们放在您的类路径中。

记住对所有引用的工件递归执行此操作,直到您拥有 Maven 会为您下载的所有 jar 文件。

例如,如果您需要 commons lang,您可以从 https://search.maven.org/artifact/org.mod4j.org.apache.commons/lang/2.1.0/jar 获得 2.1 - 请注意右上角的下载 link。

您可能会发现将现有内容重新加工成 Maven 项目更容易,因此您的工具会为您完成。