多个SLF4J绑定intellij linux

时间:2015-10-06 01:58:27

标签: java linux intellij-idea gradle

我正在尝试从IntelliJ的想法中运行由gradle生成的战争。

当我通过想法的tomcat运行配置运行战争时,我得到SLF4J多重绑定警告如下:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/share/java/slf4j-jcl-1.7.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/share/java/slf4j-jdk14-1.7.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/share/java/slf4j-simple-1.7.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/share/java/slf4j-nop-1.7.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/share/java/slf4j-log4j12-1.7.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/share/java/logback-classic-1.1.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/virtue/prog/idea_project/out/artifacts/websitebase-app/exploded/websitebase-app-1.0.0.war/WEB-INF/lib/logback-classic-1.1.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]

websitebase-app-1.0.0.war中的SLF4J是我的应用程序中的一个。来自/ usr / share / java的SLF4J绑定是我不想要的额外SLF4J绑定。我不知道如何删除它们,因为当我从gradle运行应用程序时,我没有在运行时包含它们。

如何配置我的应用程序或IntelliJ创意,而不是包含那些额外的SLF4J绑定?

我正在尝试在IntelliJ中启动应用程序。我在IntelliJ中创建了一个使用我本地安装的tomcat7的运行配置。我从存储库安装了tomcat,我运行的是NetRunner 16,它是Kubuntu的发行版。

运行tomcat实例时jps -v的输出:

5281 Jps -Dapplication.home=/usr/lib/jvm/java-8-oracle -Xms8m
4808 RemoteMavenServer -Djava.awt.headless=true -Didea.version==14.1.5 -Xmx512m -Didea.maven.embedder.version=3.0.5 -Dfile.encoding=UTF-8
5164 Launcher -Xmx700m -Djava.awt.headless=true -Djava.endorsed.dirs="" -Djdt.compiler.useSingleThread=true -Dpreload.project.path=/home/virtue/prog/idea_project -Dpreload.config.path=/home/virtue/.IntelliJIdea14/config/options -Dcompile.parallel=false -Drebuild.on.dependency.change=true -Djava.net.preferIPv4Stack=true -Dio.netty.initialSeedUniquifier=7407435799211631797 -Dfile.encoding=UTF-8 -Djps.file.types.component.name=FileTypeManager -Duser.language=en -Duser.country=CA -Didea.paths.selector=IntelliJIdea14 -Didea.home.path=/home/virtue/devtools/idea/idea-IU-141.2735.5 -Didea.config.path=/home/virtue/.IntelliJIdea14/config -Didea.plugins.path=/home/virtue/.IntelliJIdea14/config/plugins -Djps.log.dir=/home/virtue/.IntelliJIdea14/system/log/build-log -Djava.io.tmpdir=/home/virtue/.IntelliJIdea14/system/compile-server/_temp_
4669 Main -Xbootclasspath/a:/home/virtue/devtools/idea/idea-IU-141.2735.5/bin/../lib/boot.jar -Xms128m -Xmx750m -XX:MaxPermSize=350m -XX:ReservedCodeCacheSize=225m -XX:+UseConcMarkSweepGC -XX:SoftRefLRUPolicyMSPerMB=50 -ea -Dsun.io.useCanonCaches=false -Djava.net.preferIPv4Stack=true -Dawt.useSystemAAFontSettings=lcd -Djb.vmOptionsFile=/home/virtue/devtools/idea/idea-IU-141.2735.5/bin/idea64.vmoptions -XX:ErrorFile=/home/virtue/java_error_in_IDEA_%p.log -Djb.restart.code=88 -Didea.paths.selector=IntelliJIdea14
4958 GradleDaemon -XX:MaxPermSize=1024m -Dfile.encoding=UTF-8 -Duser.country=CA -Duser.language=en -Duser.variant
5167 Bootstrap -Djava.util.logging.config.file=/home/virtue/.IntelliJIdea14/system/tomcat/Unnamed_marble-gradle-common_3/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:48465,suspend=y,server=n -javaagent:/home/virtue/devtools/idea/idea-IU-141.2735.5/plugins/Groovy/lib/agent/gragent.jar -Dcom.sun.management.jmxremote= -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Djava.rmi.server.hostname=127.0.0.1 -Djava.endorsed.dirs=/usr/share/tomcat7/endorsed -Dcatalina.base=/home/virtue/.IntelliJIdea14/system/tomcat/Unnamed_marble-gradle-common_3 -Dcatalina.home=/usr/share/tomcat7 -Djava.io.tmpdir=/home/virtue/.IntelliJIdea14/system/tomcat/Unnamed_marble-gradle-common_3/temp

1 个答案:

答案 0 :(得分:0)

这里有几种解决方案:

  • 确保在类路径中只包含一个slf4j依赖项。
  • 如果您的项目依赖于其他项目而另一个项目使用slf4j以及不同版本尝试使用 excusion
<exclusions>
   <exclusion>
       <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
    </exclusion>
</exclusions>