私のプロジェクトで矛盾する依存関係に問題があります。特に、そこにSLF4Jロギングの2つの実装です:SLF4J - シンプルでlogback-classicが、私は、実行時にmavenの依存関係を除外する
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/apykhtin/.m2/repository/org/slf4j/slf4j-simple/1.7.19/slf4j-simple-1.7.19.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/apykhtin/.m2/repository/ch/qos/logback/logback-classic/1.1.3/logback-classic-1.1.3.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 [org.slf4j.impl.SimpleLoggerFactory]
Exception in thread "main" java.lang.IllegalStateException: Unable to acquire the logger context
at io.dropwizard.logging.LoggingUtil.getLoggerContext(LoggingUtil.java:46)
を取得しています。
logback-classicは私にとっては必須の依存関係です(dropwizardのため)。しかし、slf4j-simpleは実際にはそうではありません。私は自分のプロジェクトから削除したいと思います。それだけでは簡単ではありません。
私の "uber jar"は "small jar"に依存しています。これは "slf4j-simple"に依存しています。ユーバージャーのポンポンで除外を置くことを支援されていません:小さな瓶は「影」されているので
<dependency>
<groupId>com.my.unique.group</groupId>
<artifactId>small-jar</artifactId>
<version>0.1.2-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</exclusion>
</exclusions>
</dependency>
私は思います。私の "uber-jar"はmaven-shade-pluginを使用していますが、 "small-jar"はそうではありません。 私はまた、SLF4J、簡単な陰影から除外しようとした:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.6</version>
<configuration>
<artifactSet>
<excludes>
<exclude>org.slf4j:slf4j-simple:jar</exclude>
</excludes>
</artifactSet>
...
</plugin>
も成功せず。 slf4j-simpleはまだ私のuber-jarに含まれています。 これまでの私の開発は、すべて「uber-jar」に関連していました。 「小さな瓶」のコードを変更することは可能ですが、私はそれを避けたいと思います。
私は間違っていますか?
更新:maven-shade-pluginはここでの犯人ではありません。このプラグインを完全にオフにして、まったく同じエラーが発生しました。 – Alexander
更新2:明らかに私の問題は、プロジェクトの誤設定に起因していました。すべて(Mavenリポジトリを含む)をクリアし、新鮮なソースをチェックアウトし、Eclipseでプロジェクトを作成すると、すべてが期待どおりに機能しています。みんなありがとう。 – Alexander