美文网首页
启动项目时提示java.lang.NoClassDefFound

启动项目时提示java.lang.NoClassDefFound

作者: 飞翔的肥猫 | 来源:发表于2018-07-15 18:32 被阅读0次

原因是因为依赖项中有多个日志工具,而slf4j不知道要使用哪个日志工具。
Pom中把Springboot默认的logback-classic替换

 <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>

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>

或者指明使用slf4j

    <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.6.1</version>
    </dependency>


    <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12 -->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.6.1</version>
        <scope>test</scope>
    </dependency>

相关文章

网友评论

      本文标题:启动项目时提示java.lang.NoClassDefFound

      本文链接:https://www.haomeiwen.com/subject/pmoppftx.html