启动spring boot 异常

  再我搭建spring boot工程后,run application的时候抛出下面异常

 Exception in thread "main" 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:/Users/zhangxs/.m2/repository/org/slf4j/slf4j-log4j12/1.7.13/slf4j-log4j12-1.7.13.jar). If you are using WebLogic you will need to add 'org.slf4j' to prefer-application-packages in WEB-INF/weblogic.xml Object of class [org.slf4j.impl.Log4jLoggerFactory] must be an instance of class ch.qos.logback.classic.LoggerContext
我在repostory 里删除slf4j-log4j12-1.7.13.jar 这个jar包后,确实是可以运行的,
slf4j是公司的jar里依赖的jar.所以就只能对自己的工程做配置。
解决方法:
在spring -boot- starter和spring -boot-starter- web上添加排斥来解决冲突。
<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                  <groupId>org.springframework.boot</groupId>
                  <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
              </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
              <exclusions>
                <exclusion>
                  <groupId>org.springframework.boot</groupId>
                  <artifactId>spring-boot-starter-logging</artifactId>
               </exclusion>
         </exclusions>
</dependency>
原文地址:https://www.cnblogs.com/zhangXingSheng/p/7606260.html