Spring Boot项目在run上失败并给出以下错误。是什么导致此错误,我该如何预防。

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/z00381z/.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-slf4j-impl/2.11.1/4b41b53a3a2d299ce381a69d165381ca19f62912/log4j-slf4j-impl-2.11.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/z00381z/.gradle/caches/modules-2/files-2.1/ch.qos.logback/logback-classic/1.1.11/ccedfbacef4a6515d2983e3f89ed753d5d4fb665/logback-classic-1.1.11.jar!/org/slf4j/impl/StaticLoggerBinder.class]

Gradle文件
buildscript {
  repositories {
    maven { url "https://binrepo.mycompany.com/artifactory/platform" }
    maven { url "https://binrepo.mycompany.com/artifactory/maven-central" }
    jcenter()
    mavenCentral()
    maven {
      url "https://plugins.gradle.org/m2/"
    }
  }
  dependencies {
    classpath "com.mycompany.platform:platform-connector-gradle:1.1.4"
  }
}

apply plugin: 'org.springframework.boot'
apply plugin: "com.mycompany.platform.connector.spring-boot"
apply plugin: "io.spring.dependency-management"

mainClassName = "com.mycompany.learnattargetuser.Main"

version = "0.0.1"

distTar.version = ""

dependencies{
    compile "org.springframework.boot:spring-boot-starter-data-jpa"
}

最佳答案

注意,冲突来自两个jar,分别是 logback.jar log4j-slf4j-impl-.jar
现在,选择您要忽略的那个。
我将忽略slf4j-log4j12。

在漱口液中

 configurations.all {
        exclude module: 'slf4j-log4j12'
    }

或忽略登录。
configurations {
    all*.exclude module : 'spring-boot-starter-logging'
}

关于spring-boot - 带有gradle的Spring Boot项目因错误而失败-多个绑定(bind),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/53816366/

10-11 22:25
查看更多