Java异常: Found interface … but class was expected

佴阳曦
2023-12-01

This happens when your runtime classpath is different than your compile time classpath.

这个异常是由于你的运行时classpath和编译时classpath 不一致。

When your application was compiled, a class (named SomeInterface in your question) existed as a class.

When your application is running at compile time, SomeInterface exists as an interface (instead of a class.)

当你的应用编译时,一个叫SomeInterface 的类以类的形式存在;但是当应用编译运行时,SomeInterface 却以接口的形式出现(而不是类的形式)

This causes an IncompatibleClassChangeError to be thrown at runtime.

这会导致运行时抛出IncompatibleClassChangeError 异常。

This is a common occurence if you had a different version of a jar file on the compile time classpath than on the runtime classpath.

当jar包在编译时 classpath和运行时classpath中是不同版本,就经常会出现这个问题。

总结:jar包版本冲突
 类似资料: