簡體   English   中英

Gradle intelliJ 插件 SLF4J:類路徑包含多個 SLF4J 綁定

[英]Gradle intelliJ plugin SLF4J: Class path contains multiple SLF4J bindings

我正在為 intelliJ IDEA 開發一個插件,並且我正在使用一個外部庫。 當我跑步時,我遇到了這個問題。

SLF4J:類路徑包含多個 SLF4J 綁定。 SLF4J:在 [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:在 [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/slfclass4j/www.impls/org/slfclass4j] http://www.ideaic.com/ org/codes.html#multiple_bindings的解釋。

這是我的 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'
}

我嘗試了我發現的許多解決方案,但我無法解決。

有人能幫我嗎?

我在最近使用 Gradle 6.7 和 Spring Boot 2.3.4.RELEASE 的應用程序中遇到了同樣的問題。 我最終排除了 IntelliJ 插件引入的內容以及其他一些內容。

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')
}

它的那種蠻力,但它的工作原理。 也許 Gradle 文件中缺少一些設置,導致添加了這些不必要的模塊。 我當然不希望這些插件將這些東西添加到我的 JAR 中。

我能夠通過排除build.gradle.kts文件中的slf4j-api依賴項來解決這個問題。

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")
     }

}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM