Java 如何修复 ClassNotFoundException:org.apache.commons.logging.LogFactory?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24796112/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 14:52:22  来源:igfitidea点击:

How to fix ClassNotFoundException: org.apache.commons.logging.LogFactory?

javaapache-commons-logging

提问by jvd

When i run the app it getting exception

当我运行应用程序时,它出现异常

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
    at org.hibernate.dialect.Dialect.<clinit>(Dialect.java:58)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
    at java.net.URLClassLoader.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    ... 1 more

I have put all the jar files in lib folder. I don't know how to solve this, where is my mistake.

我已将所有 jar 文件放在 lib 文件夹中。我不知道如何解决这个问题,我的错误在哪里。

回答by bumbumpaw

Include hibernate jar files (especially the required jars) in your libfolder

在您的lib文件夹中包含休眠 jar 文件(尤其是所需的 jar)

antlr-2.7.7.jar
commons-collections-3.2.1.jar
dom4j-1.6.1.jar
javassist-3.12.1.GA.jar
hibernate-core-4.0.1.Final.jar
hibernate-commons-annotations-4.0.1.Final.jar
hibernate-jpa-2.0-api-1.0.1.Final.jar
jboss-logging-3.1.0.CR2.jar
jboss-transaction-api_1.1_spec-1.0.0.Final.jar

回答by Joao Luiz Cadore

Add this in your pom file:

在你的 pom 文件中添加:

<dependency>
    <groupId>commons-logging</groupId>
    <artifactId>commons-logging</artifactId>
    <version>1.2</version>
</dependency>

回答by Christian Hofer

I had a similar problem: In my project the solution was to add the following jars of org.apache.commons:

我有一个类似的问题:在我的项目中,解决方案是添加以下 org.apache.commons jars:

commons-logging-1.2 commons-dbcp2-2.1.1 commons-pool2-2.4.2

commons-logging-1.2 commons-dbcp2-2.1.1 commons-pool2-2.4.2

回答by Gaurav Garg

For me problem solved post download & adding jar "commons-logging-1.2.jar"

对我来说,问题解决后下载并添加 jar“commons-logging-1.2.jar”

回答by Kishore Babu

It works for me after adding this jar file

添加此 jar 文件后它对我有用

commons-logging-1.2.jar

commons-logging-1.2.jar

You can download it from here.

你可以从这里下载。