Java Eclipse RCP 插件中的多个 slf4j 绑定
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18721142/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
multiple slf4j bindings in Eclipse RCP Plugin
提问by Absurd-Mind
I have a simple Eclipse Plugin which gives me following error on activation:
我有一个简单的 Eclipse 插件,它在激活时出现以下错误:
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [bundleresource://103.fwk8918249:1/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [bundleresource://103.fwk8918249:4/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
both URLs resolve to the exact same jar in the bundle
两个 URL 都解析为包中完全相同的 jar
libs/slf4j-log4j12.jar!/org/slf4j/impl/StaticLoggerBinder.class
- How can i solve the problem?
- How come that the bundle loads the jar twice (":1" and ":4")?
- 我该如何解决问题?
- 为什么包两次加载罐子(“:1”和“:4”)?
回答by Calon
This seems to solve the problem: SLF4J: Class path contains multiple SLF4J bindings
这似乎解决了问题: SLF4J: Class path contains multiple SLF4J bindings
If not, do you have two different versions of SLF4J on that path?
如果没有,那条路径上是否有两个不同版本的 SLF4J?
回答by jdknight
This is a result of defining an SLF4J binding in both your project's classpath (JDT .classpath file) and your MANIFEST.MF file.
这是在项目的类路径(JDT .classpath 文件)和 MANIFEST.MF 文件中定义 SLF4J 绑定的结果。
You should remove your SLF4J binding from your project's class path:
您应该从项目的类路径中删除 SLF4J 绑定:
YourProject → Properties → Java Build Path → Libraries
- Select the SLF4J Binding JAR and hit 'Remove'.
YourProject → 属性 → Java 构建路径 → 库
- 选择 SLF4J 绑定 JAR 并点击“删除”。
Once you do this, there should only be a single reference to your SLF4J binding in your class loader (and thus the error message should not appear).
执行此操作后,类加载器中应该只有一个对 SLF4J 绑定的引用(因此不应出现错误消息)。
回答by Stefan
For me the issue occurred due to an installed plugin. To find out which one it is.. look for the file SavedExternalPluginList.txt in the metadata of the debugging eclipse instance, e.g.
对我来说,问题是由于安装了插件而发生的。要找出它是哪个.. 在调试 eclipse 实例的元数据中查找文件 SavedExternalPluginList.txt,例如
runtime-EclipseApplication\.metadata\.plugins\org.eclipse.pde.core\SavedExternalPluginList.txt
and search for slf4j. This way you get an idea which plugins might be responsible. I found following entries:
并搜索 slf4j。通过这种方式,您可以了解哪些插件可能负责。我发现以下条目:
file:/D:/EclipseJava/App/Eclipse/plugins/ch.qos.logback.slf4j_1.0.7.v201505121915.jar
file:/D:/EclipseJava/App/Eclipse/plugins/org.eclipse.m2e.maven.runtime.slf4j.simple_1.7.0.20160603-1931/
file:/D:/EclipseJava/App/Eclipse/plugins/org.slf4j.api_1.7.2.v20121108-1250.jar
file:/D:/EclipseJava/App/Eclipse/plugins/org.slf4j.impl.log4j12_1.7.2.v20131105-2200.jar
Disabling the plugin ch.qos.logback.slf4j for my Target Platform did the trick:
为我的目标平台禁用插件 ch.qos.logback.slf4j 可以解决问题:
If you manually change the plugin selection, please be careful and use the Validate Plug-insfeature to make sure you don't create other issues.
如果您手动更改插件选择,请小心并使用验证插件功能以确保您不会产生其他问题。