1
votes

I'm developing a plugin for intelliJ IDEA and I'm using an external library. When I run, I have this problem.

SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/C:/Users/molos/Desktop/Thesis-folder/Thesis-project/build/idea-sandbox/plugins/Thesis-project/lib/slf4j-log4j12-1.6.0.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/C:/Users/molos/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIC/2019.3.1/52292e4f8a0ccb3ceb08bd81fd57b88923ac8e99/ideaIC-2019.3.1/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.

This is my build.gradle.

plugins {
id 'java'
id 'maven-publish'
id 'org.jetbrains.intellij' version '0.4.10'
}

version '1.0-SNAPSHOT'

apply plugin: 'maven'

sourceCompatibility = 1.8

repositories {
   mavenCentral()
   maven {
      url = 'https://repo.maven.apache.org/maven2'
}


dependencies {
  // https://mvnrepository.com/artifact/com.github.mauricioaniche/ck
compile group: 'com.github.mauricioaniche', name: 'ck', version: '0.4.4'
// https://mvnrepository.com/artifact/org.eclipse.jgit/org.eclipse.jgit
compile group: 'org.eclipse.jgit', name: 'org.eclipse.jgit', version: '2.2.0.201212191850-r'
// https://mvnrepository.com/artifact/org.apache.commons/commons-csv
compile group: 'org.apache.commons', name: 'commons-csv', version: '1.1'



}

// See https://github.com/JetBrains/gradle-intellij-plugin/
intellij {
version '2019.3.1'
}

I tried the many solutions that I found around, but I could not solve.

Can someone help me?

2
did you try clearing m2 folder and re-installing your dependencies? If you did it and still finding the same problem, then there are dependencies that are downloading SLF4J as lateral dependencies, if you can post your pom.xml file, probably me or someone might be able to help you.pavan kumar
I tried to clean m2 folder and other idea folders. I edit post with build.gradleMaurizio Sellitti
I would try to search the slf4j dependency from the other dependencies. You should exclude it from the other dependencies and just add one yourself in your build.gradle. Another thing I would recommend is to use the force command. Look here docs.gradle.org/current/dsl/…harshvardhan.agr
I was assuming it was maven build... my bad no point in clearing .m2 try clearing gradle cachepavan kumar

2 Answers

0
votes

I had the same problem in a recent app with Gradle 6.7 and Spring Boot 2.3.4.RELEASE. I ended up excluding what the IntelliJ plugin was pulling in, and a few other things.

plugins {
    id 'java'
    id 'org.jetbrains.intellij' version '0.5.1'
    id 'org.springframework.boot' version '2.3.4.RELEASE'
    id 'io.spring.dependency-management' version '1.0.10.RELEASE'
}
...
configurations {
    // the ideaIC module is adding the slf4j-log4j12 module and StaticLoggerBinder.class
    implementation.exclude(group: 'com.jetbrains', module: 'ideaIC')
    
    // the groovy plugin was adding groovy to the runtime
    implementation.exclude(group: 'org.codehaus.groovy', module: 'groovy-all')

    // spring-boot-logging brought in logback and log4j-to-slf4j which I don't want
    //   since I am using org.springframework.boot:spring-boot-starter-log4j2
    compile.exclude(group: 'ch.qos.logback')
    compile.exclude(group: 'org.apache.logging.log4j', module: 'log4j-to-slf4j')
}

Its kind of brute-force, but it works. Maybe there is some setting missing in the Gradle file that results in these unnecessary modules being added. I certainly don't expect these plugins to add such things to my JAR.

0
votes

I was able to remedy this problem by excluding the slf4j-api dependency inside my build.gradle.kts file.

dependencies {
    detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.17.1")

    // JGIT
     implementation(group="org.eclipse.jgit", name="org.eclipse.jgit", version="5.11.1.202105131744-r"){
           exclude(group="org.slf4j", module="slf4j-api")
     }

}