Java NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder

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

NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder

javatilesslf4j

提问by javanoob

I'm trying to run the sample tiles example given here.

我正在尝试运行此处给出的示例图块示例。

Below is my POM.xml:

下面是我的 POM.xml:

<dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.tiles</groupId>
            <artifactId>tiles-api</artifactId>
            <version>2.1.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tiles</groupId>
            <artifactId>tiles-core</artifactId>
            <version>2.1.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tiles</groupId>
            <artifactId>tiles-jsp</artifactId>
            <version>2.1.2</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.5.2</version>
        </dependency>

When I'm trying to run the example the below error is thrown:

当我尝试运行示例时,抛出以下错误:

Sep 17, 2010 11:59:43 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Error configuring application listener of class      org.apache.tiles.web.startup.TilesListener
java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
at org.slf4j.LoggerFactory.<clinit>(LoggerFactory.java:60)
at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:155)
at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:131)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:685)
at org.apache.tiles.web.startup.TilesListener.<init>(TilesListener.java:49)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)

Any idea?

任何的想法?

I spent 30 minutes googling for this but could not find a possible sollution.

我花了 30 分钟为此搜索了 30 分钟,但找不到可能的解决方案。

Please help me...

请帮我...

采纳答案by gpeche

You have included a dependency on the SLF4J API, which is what you use in your application for logging, but you must also include an implementation that does the real logging work.

您已经包含了对 SLF4J API 的依赖,这是您在应用程序中用于日志记录的内容,但您还必须包含一个执行实际日志记录工作的实现。

For example to log through Log4J you would add this dependency:

例如,要通过 Log4J 登录,您将添加此依赖项:

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.5.2</version>
    </dependency>

The recommended implementation would be logback-classic, which is the successor of Log4j, made by the same guys that made SLF4J and Log4J:

推荐的实现是 logback-classic,它是 Log4j 的继承者,由制作 SLF4J 和 Log4J 的同一个人制作:

<dependency>
    <groupId>ch.qos.logback</groupId>
    <artifactId>logback-classic</artifactId>
    <version>0.9.24</version>
</dependency>

Note: The versions may be incorrect.

注意:版本可能不正确。

回答by Nathan Hughes

You have included the dependency for sflj's api, but not the dependency for the implementation of the api, that is a separate jar, you could try slf4j-simple-1.6.1.jar.

你已经包含了sflj的api的依赖,但没有包含实现api的依赖,那是一个单独的jar,你可以试试slf4j-simple-1.6.1.jar。

回答by user4856159

Add the all tiles jars like(tiles-jsp,tiles-servlet,tiles-template,tiles-extras.tiles-core ) to your server lib folder and your application build path then it work if you using apache tailes with spring mvc application

将所有tiles jars like(tiles-jsp,tiles-servlet,tiles-template,tiles-extras.tiles-core) 添加到你的服务器lib文件夹和你的应用程序构建路径,然后如果你在spring mvc应用程序中使用apache tailes,它就可以工作

回答by Vivek

Copy all order entries of home folder .iml file into your /src/main/main.iml file. This will solve the problem.

将主文件夹 .iml 文件的所有订单条目复制到您的 /src/main/main.iml 文件中。这将解决问题。

回答by Mateen

i had the same error while working with hibernate, i had added below dependency in my pom.xml that solved the problem

我在使用 hibernate 时遇到了同样的错误,我在 pom.xml 中添加了以下依赖项来解决这个问题

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.10</version>
    </dependency>

reference https://mvnrepository.com/artifact/org.slf4j/slf4j-api

参考 https://mvnrepository.com/artifact/org.slf4j/slf4j-api