SpringBoot启动:LoggerFactory is not a Logback LoggerContext but Logback is on the classpath

  • 可能原因一:slf4j异常及解决办法

  • 可能原因二:在SpringBoot项目里面,日志的绑定顺序有严格要求

解决办法:调整SpringBoot相关pom.xml文件,将引入的SpringBoot配置文件放在最前。

<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <version>2.2.2.RELEASE</version>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-webflux</artifactId>
            <version>2.2.2.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>2.2.2.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <version>2.2.2.RELEASE</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        
        <!-- 其他需要引用的 GAV 在SpringBoot后面添加 ...  -->
   </dependencies>

猜你喜欢

转载自blog.csdn.net/xxyybs/article/details/103703019