• 【原创】大叔经验分享(67)spring boot启动报错


    spring boot 启动报错:

    Caused by: java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class org.slf4j.impl.Log4jLoggerFactory loaded from file:/usr/local/tomcat/webapps/app/WEB-INF/lib/slf4j-log4j12-1.7.25.jar). If you are using WebLogic you will need to add 'org.slf4j' to prefer-application-packages in WEB-INF/weblogic.xml: org.slf4j.impl.Log4jLoggerFactory
            at org.springframework.util.Assert.instanceCheckFailed(Assert.java:655)
            at org.springframework.util.Assert.isInstanceOf(Assert.java:555)
            at org.springframework.boot.logging.logback.LogbackLoggingSystem.getLoggerContext(LogbackLoggingSystem.java:286)
            at org.springframework.boot.logging.logback.LogbackLoggingSystem.beforeInitialize(LogbackLoggingSystem.java:102)
            at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationStartingEvent(LoggingApplicationListener.java:220)
            at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:199)
            at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
            at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
            at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
            at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
            at org.springframework.boot.context.event.EventPublishingRunListener.starting(EventPublishingRunListener.java:69)
            at org.springframework.boot.SpringApplicationRunListeners.starting(SpringApplicationRunListeners.java:48)
            at org.springframework.boot.SpringApplication.run(SpringApplication.java:302)
            at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:157)
            at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:137)
            at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:91)
            at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:171)
            at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5139)
            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
            ... 26 more

    出现这个问题通常的原因工程中使用了多个开源jar,每个开源jar都有自己的日志实现方式,比如slf+log4j,slf+logback等,其中slf是一个抽象接口,有很多种实现,但是工程中只能有一种,解决方法在异常中已经提示出来:

    Either remove Logback or the competing implementation (class org.slf4j.impl.Log4jLoggerFactory loaded from file:/usr/local/tomcat/webapps/app/WEB-INF/lib/slf4j-log4j12-1.7.25.jar). 

    需要在logback和slf-log4j之间去掉一个,其中spring boot用的是logback,可以去掉slf-log4j;

    通过

    mvn dependency:tree

    可以看到那些jar中依赖了slf-log4j,然后修改pom,将其排除掉

            <dependency>
                <groupId>org.apache.hadoop</groupId>
                <artifactId>hadoop-client</artifactId>
                <version>2.6.5</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.slf4j</groupId>
                        <artifactId>slf4j-log4j12</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>

    然后打包即可;

  • 相关阅读:
    关于eclipse 的 web.xml文件 There is '1' error in 'j2ee_1_4.xsd'. 错误
    C#实现Java的AES加密解密算法
    jsp页面报错javax.servlet.jsp.jspException cannot be resolved to a type
    Ubuntu下查看jdk安装路径
    【Mysql】启动mysql报错mysqld_safe error: log-error set to /var/log/mariadb/mariadb.log
    spring mvc导出csv案例
    MyBatis 调用存储过程(详解)
    mysql 无限递归出现 data too long for column 'xxx' 错误
    java的maven项目头上有红叉解决方法
    Nexus3搭建Docker等私服
  • 原文地址:https://www.cnblogs.com/barneywill/p/11013719.html
Copyright © 2020-2023  润新知