NoClassDefFoundError: Could not initialize class org.slf4j.MDC

NoClassDefFoundError: Could not initialize class org.slf4j.MDC

如何修复 NoClassDefFoundError: Could not initialize class org.slf4j.MDC?我有 pom.xml flyway 插件,其中 slf4j 被排除在外,支持更新的插件。

[INFO] |  \- org.slf4j:slf4j-simple:jar:1.5.6:compile
[INFO] +- org.springframework:spring-beans:jar:4.1.4.RELEASE:compile
[INFO] +- org.springframework:spring-core:jar:4.1.4.RELEASE:compile
[INFO] |  \- commons-logging:commons-logging:jar:1.2:compile
[INFO] +- org.springframework:spring-webmvc:jar:4.1.4.RELEASE:compile
[INFO] |  +- org.springframework:spring-expression:jar:4.1.4.RELEASE:compile
[INFO] |  \- org.springframework:spring-web:jar:4.1.4.RELEASE:compile
[INFO] +- org.springframework:spring-tx:jar:4.1.4.RELEASE:compile
[INFO] +- org.springframework:spring-jdbc:jar:4.1.4.RELEASE:compile
[INFO] +- org.springframework:spring-orm:jar:4.1.4.RELEASE:compile
[INFO] +- org.springframework:spring-context:jar:4.1.4.RELEASE:compile
[INFO] |  \- org.springframework:spring-aop:jar:4.1.4.RELEASE:compile
[INFO] |     \- aopalliance:aopalliance:jar:1.0:compile
[INFO] +- ch.qos.logback:logback-classic:jar:1.1.2:compile
[INFO] |  +- ch.qos.logback:logback-core:jar:1.1.2:compile
[INFO] |  \- org.slf4j:slf4j-api:jar:1.7.6:compile
[INFO] +- org.slf4j:jcl-over-slf4j:jar:1.7.10:compile

pom.xml

<dependency>
            <groupId>org.flywaydb.flyway-test-extensions</groupId>
            <artifactId>flyway-spring4-test</artifactId>
            <version>3.1</version>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

<dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>${logback.version}</version>
        </dependency>
<dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <version>${jcloverslf4j.version}</version>
        </dependency>
org.slf4j:slf4j-simple:jar:1.5.6:compile
org.slf4j:slf4j-api:jar:1.7.6:compile
org.slf4j:jcl-over-slf4j:jar:1.7.10:compile

这些版本需要匹配。他们不匹配。至少,次要版本(1.X 中的 X)需要匹配。另外,如果您使用的是 logback,请摆脱 slf4j-simple。类路径上应该只有一个 slf4j 后端。