在eclipse luna中使用JGit时获取NoClassDefFoundError [英] Getting NoClassDefFoundError while using JGit in eclipse luna

查看:452
本文介绍了在eclipse luna中使用JGit时获取NoClassDefFoundError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近下载了eclipse luna并通过Eclipse安装了EGit插件。我可以在eclipse / plugins文件夹中看到下载jar文件。然后我将JGit jar文件添加到我的构建路径中,我可以看到 Referenced Libraries 文件夹中的类文件。

但是,当我运行项目时,我得到以下内容错误

I recently download eclipse luna and installed the EGit plugin through Eclipse. I can see the download jar files in eclipse/plugins folder. I then added the JGit jar file to my build path and I can see the class files inside my Referenced Libraries folder.
However, when I run the project I get the following error

Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at org.eclipse.jgit.util.FS.<clinit>(FS.java:112)
at org.eclipse.jgit.lib.BaseRepositoryBuilder.setupWorkTree(BaseRepositoryBuilder.java:620)
at org.eclipse.jgit.lib.BaseRepositoryBuilder.setup(BaseRepositoryBuilder.java:556)
at org.eclipse.jgit.storage.file.FileRepositoryBuilder.build(FileRepositoryBuilder.java:92)
at org.eclipse.jgit.storage.file.FileRepositoryBuilder.create(FileRepositoryBuilder.java:110)
at upload_gen.Launcher.main(Launcher.java:16)

Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 6 more

我搜索了一个问题,说这可能是因为我的类路径不包含jar文件。但是当我检查运行|运行配置中的类路径选项卡时,它似乎包含了jar文件。我还检查了根文件夹中的.classpath文件,看起来像这样

I googled the problem which said that it might be because my classpath doesn't include the jar file. But when I check the the classpath tab in "run | run configuration" it seems to be including the jar file. I also checked the .classpath file in the root folder which looks like this

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry exported="true" kind="lib" path="lib/org.eclipse.jgit_3.7.0.201502260915-r.jar"/>
<classpathentry kind="var" path="JGIT_JARS"/>
<classpathentry kind="output" path="bin"/>
</classpath>

我还尝试将JGit jar文件添加到项目根目录中的lib文件夹中请参阅上面的.classpath文件。
简而言之,我尝试在外部和内部添加jar文件,但我仍然收到错误。我也尝试使用类变量引用jar文件,但这也不起作用。编译项目时也没有错误,只有在项目运行时才会出错。

I also tried adding the JGit jar file in the lib folder in the root of my project as you can see in the above .classpath file. In short, I tried adding the jar file externally as well as internally but I'm still getting the error. I also tried referencing the jar file using a class variable but that doesn't work either. Also there are no errors while compiling the project, getting error only when the project is run.

推荐答案

你可能需要添加一个slf4j jar到Eclipse中的库。

You probably need to add a slf4j jar to the libraries in Eclipse.

这篇关于在eclipse luna中使用JGit时获取NoClassDefFoundError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆