java 这个错误有什么问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5403525/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 10:57:59  来源:igfitidea点击:

what's wrong for this error

javaspringslf4j

提问by user496949

Spring framework throws

Spring 框架抛出

Exception in thread "main" java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V
    at org.apache.commons.logging.impl.SLF4JLocationAwareLog.info(SLF4JLocationAwareLog.java:159)
    at org.springframework.context.support.AbstractApplicationContext.prepareRefresh(AbstractApplicationContext.java:454)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:392)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)

what's the reason?

什么原因?

回答by Jigar Joshi

The reason is wrong version of library added (version conflict).

原因是添加的库版本错误(版本冲突)。

Check for the version of slf4j's javadoc and try to figure out ,this method exist with which version ?

检查slf4j's javadoc的版本并尝试找出该方法存在于哪个版本?

回答by cam

If you are running OSX you might find this is because the following files are included as java extensions:

如果您运行的是 OSX,您可能会发现这是因为以下文件作为 java 扩展名包含在内:

/Library/Java/Extensions/slf4j-api-1.5.8.jar

/Library/Java/Extensions/slf4j-api-1.5.8.jar

/Library/Java/Extensions/slf4j-log4j12-1.5.8.jar

/Library/Java/Extensions/slf4j-log4j12-1.5.8.jar

These are loaded by the extension classloader, before your application classloader, so these will be resolved first.

这些由扩展类加载器在您的应用程序类加载器之前加载,因此将首先解决这些问题。

I have no idea why these are there or when they were added but i've only seen this on OSX and in the last year, which might imply they were introduced in java 6.

我不知道为什么这些在那里或何时添加,但我只在 OSX 和去年看到过这个,这可能意味着它们是在 java 6 中引入的。

You can remove\move the files to workaround the problem, but there might be some applications which depend on them.

您可以删除\移动文件来解决问题,但可能有一些应用程序依赖于它们。

回答by Kanagaraj M

You might be having a class twice in your classpath.

您的类路径中可能有两次类。

Check the classpath for the occurrences.

检查发生的类路径。