我如何“安装"?一个 log4j 包?

2022-01-16 00:00:00 eclipse-plugin eclipse log4j osgi

我已经下载了 Eclipse 插件的代码.该代码使用 log4j,但它不仅将其用作库(称为 jar),还用作捆绑包".所以它没有编译,原因如下:

I've downloaded the code for an Eclipse plugin. The code uses log4j, but it doesn't just use it as a library (referred jar), but as a "bundle". So it doesn't compile because of the following reason:

无法解析捆绑org.apache.log4j"

Bundle 'org.apache.log4j' cannot be resolved

我不确定解决此问题的正确方法是什么.我知道如何将 jars 添加到项目中,但是如何添加捆绑包"?我需要将它添加到整个 Eclipse 主机吗?

I'm not really sure what's the correct approach to solve this. I know how to add jars to a project, but how do I add "bundles"? Is it something I need to add to the entire Eclipse host?

我通过创建一个没有代码但包含 log4j jar 的新插件项目解决"了这个问题......但这感觉不是正确的解决方案.

I "solved" this by creating a new plugin project with no code but with the log4j jar included... but that doesn't feel like the right solution.

我还发现了一些发布log4j 包"的地方,例如:

I've also found some places where "log4j bundles" are published, e.g.:

  • http://ebr.springsource.com/repository/app/bundle/version/detail?name=com.springsource.org.apache.log4j&version=1.2.16
  • http://download.eclipse.org/tools/orbit/downloads/drops/R20110523182458/

但我不确定这是否是我需要的,我从哪里获得它是否重要,以及如何安装"它.

But I'm not sure if that's what I need, if it matters where I get it from, and how to "install" it.

推荐答案

我假设您使用的是 Eclipse 插件开发环境 (PDE).在这种情况下,需要将 log4j 捆绑包导入目标平台".

I assume you are using the Eclipse Plugin Development Environment (PDE). In this case, the log4j bundle needs to be imported into the "Target Platform".

目标平台就像一个包(即插件)的存储库,它取代了传统 Java 开发中的类路径".您可以找到目标平台的位置,并通过Preferences -> Plug-in Development -> Target Platform 进行修改.

The Target Platform is like a repository of bundles (i.e. plug-ins) that replaces the "classpath" in traditional Java development. You can find the location of the target platform and modify it by going to Preferences -> Plug-in Development -> Target Platform.

但是在此之前,我强烈建议您花一些时间了解一下您正在从事的工作!如果您想开发一个 Eclipse 插件,您至少应该了解什么是插件,以及它的依赖关系是如何工作的.如果您阅读了有关该主题的一些信息,则不必在 Stack Overflow 上问这样一个非常基本的问题……所有介绍性教程和常见问题解答都涵盖了它.

HOWEVER before doing this I strongly recommend you take some time to learn a bit about what you are working on! If you want to develop an Eclipse Plug-in you should at least learn what a plug-in is, and how its dependencies work. If you read a bit about the subject you should not have to ask such an extremely basic question on Stack Overflow... it is covered in all the introductory tutorials and FAQs.

相关文章