2017-10-04 72 views
-4

創建一個Maven的項目,我有如下jar文件:sl4j-log4j12-1.7.25但在執行我得到下面的錯誤: SLF4J:您SLF4J的請求的版本99年6月1日綁定不兼容[1.5​​.5,1.5.6] SLF4J:有關更多詳細信息,請參閱here我已經在Eclipse

Exception in thread "main" java.lang.NoSuchMethodError: org.slf4j.helpers.MessageFormatter.format(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Lorg/slf4j/helpers/FormattingTuple; at org.slf4j.impl.Log4jLoggerAdapter.info(Log4jLoggerAdapter.java:346)

回答

0

確保您的slf4j-api版本與您的slf4j-log版本相同。

你的答案在你提供的鏈接中!

slf4j-api version does not match that of the binding

An SLF4J binding designates an artifact such as slf4j-jdk14.jar or slf4j-> > log4j12.jar used to bind slf4j to an underlying logging framework, say, java.util.logging and respectively log4j. Mixing mixing different versions of slf4j-api.jar and SLF4J binding can cause problems. For example, if you are using slf4j-api-1.8.0-alpha2.jar, then you should also use slf4j-simple-1.8.0-alpha2.jar, using slf4j-simple-1.5.5.jar will not work.

NOTE From the client's perspective all versions of slf4j-api are compatible. Client code compiled with slf4j-api-N.jar will run perfectly fine with slf4j-api-M.jar for any N and M. You only need to ensure that the version of your binding matches that of the slf4j-api.jar. You do not have to worry about the version of slf4j-api.jar used by a given dependency in your project. You can always use any version of slf4j-api.jar, and as long as the version of slf4j-api.jar and its binding match, you should be fine. At initialization time, if SLF4J suspects that there may be a api vs. binding version mismatch problem, it will emit a warning about the suspected mismatch.

+0

嗨,謝謝..我添加了與slf4j-log版本相同的slf4j-api版本。但執行時得到了以下錯誤: –

+0

嗨,謝謝..我已經添加了與slf4j-log版本相同的slf4j-api版本。但是Igot出現以下錯誤:SLF4J:類路徑包含多個SLF4J綁定。 SLF4J:在[jar:file:/ C:/Users/tcsalku/Downloads/cmdChatbot/cmdChatbot/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]/impl中找到綁定/StaticLoggerBinder.class] SLF4J:有關說明,請參閱http://www.slf4j.org/codes.html#multiple_bindings。 SLF4J:實際綁定的類型爲[org.slf4j.impl.Log4jLoggerFactory] ​​ log4j:WARN無法爲記錄器找到appender(org.alicebot.ab.Bot)。 –