简体   繁体   English

NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder

[英]NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder

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...请帮帮我...

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.注意:版本可能不正确。

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

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

Copy all order entries of home folder .iml file into your /src/main/main.iml file.将主文件夹 .iml 文件的所有订单条目复制到您的 /src/main/main.iml 文件中。 This will solve the problem.这将解决问题。

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

A good practice to ensure consistency of SL4J versions is to centralize the version in a property like this:确保 SL4J 版本一致性的一个好做法是将版本集中在这样的属性中:

...
    <properties>
        <org.slf4j.version>1.5.2</org.slf4j.version><!-- SLF4J release -->
    </properties>
...
     <dependencies>
        <!-- SL4J with LOG4J implementation -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${org.slf4j.version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>${org.slf4j.version}</version>
        </dependency>
...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.lang.NoClassDefFoundError:org / slf4j / impl / StaticLoggerBinder - java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder 带有 Logback 的 SLF4J:NoClassDefFoundError:org/slf4j/impl/StaticLoggerBinder - SLF4J with Logback: NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder 嵌套的异常是java.lang.NoClassDefFoundError:org / slf4j / impl / StaticLoggerBinder - nested exception is java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder springboot2.7.5启动报错 Caused by: java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder - springboot2.7.5 start error Caused by: java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder 线程“ main”中的异常java.lang.NoSuchMethodError:org.slf4j.impl.StaticLoggerBinder.getSingleton()Lorg / slf4j / impl / StaticLoggerBinder - Exception in thread “main” java.lang.NoSuchMethodError: org.slf4j.impl.StaticLoggerBinder.getSingleton()Lorg/slf4j/impl/StaticLoggerBinder SLF4J:无法加载类“ org.slf4j.impl.StaticLoggerBinder”。 Java应用程序错误 - SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”. Java Application Error SLF4J:无法加载类“org.slf4j.impl.StaticLoggerBinder”。 在运行JUnit测试时 - SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”. when running JUnit test 错误[STDERR] SLF4J:无法加载类“ org.slf4j.impl.StaticLoggerBinder” - ERROR [STDERR] SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder” Intellij IDEA SLF4J:无法加载类“ org.slf4j.impl.StaticLoggerBinder” - Intellij IDEA SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder” 无法解决“ SLF4J:无法加载类“ org.slf4j.impl.StaticLoggerBinder””的问题 - Can't solve 'SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”' issue
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM