NoSuchMethodError org slf4j helpers MessageFormatter format

编译Maven project报错:

 

NoSuchMethodError org slf4j helpers MessageFormatter format

 

Caused by: java.lang.NoSuchMethodError: org.slf4j.helpers.MessageFormatter.format(Ljava/lang/String;Ljava/lang/Object;)Lorg/slf4j/helpers/FormattingTuple;

检查jar包slf4j-api-1.6.1.jar包里面确实有MessageFormatter.format这个方法,所以不是因为缺少jar包。

然后网上百度了好久才找到解决办法:

 

 
  1. <dependency>

  2. <groupId>org.slf4j</groupId>

  3. <artifactId>slf4j-log4j12</artifactId>

  4. <version>1.6.1</version>

  5. <type>jar</type>

  6. <scope>compile</scope>

  7. </dependency>

开始使用的版本为1.6.1的slf4j-log4j12-1.6.1.jar

后来更换成1.4.2版本的slf4j-log4j12-1.4.2.jar,因为我的maven里面就这两个版本的

 
  1. <dependency>

  2. <groupId>org.slf4j</groupId>

  3. <artifactId>slf4j-log4j12</artifactId>

  4. <version>1.4.2</version>

  5. <type>jar</type>

  6. <scope>compile</scope>

  7. </dependency>


没有报这个错误了。
解决方法时这样说的:

Solution: If you are getting above exception it means whatever jar or dependency you are using is not backward compatible with old version. In my case I was using latest version of slf4j-log4j12 as below in maven dependency which was not compatible with old version:

中文:

解决方案:如果您正处于异常状态,这意味着无论您使用的JAR或依赖项与旧版本不向后兼容。在我的情况下我是用slf4j-log4j12新版本如下在Maven的依赖与旧版本不兼容。

就是使用的其他jar不能兼容1.6.1版本的slf4j-log4j12-1.6.1.jar,这个版本太高,降低版本就行了,不过我也没找出来为什么会这样。。。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值