Java IncompatibleClassChangeError: ClassMetadataReadingVisitor 具有接口 ClassVisitor 作为超类

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16209623/
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-08-16 05:48:55  来源:igfitidea点击:

IncompatibleClassChangeError: class ClassMetadataReadingVisitor has interface ClassVisitor as super class

javaspring-mvcmaven-3

提问by Sharad Yadav

I have built a web application using spring-mvc and mongodb as database. I used maven3 to build the application.

我已经使用 spring-mvc 和 mongodb 作为数据库构建了一个 Web 应用程序。我使用 maven3 来构建应用程序。

Project builds successfully but when application starts I am getting the following error in the logs due to which my application does not start. This used to work few months ago.

项目成功构建,但当应用程序启动时,由于我的应用程序未启动,我在日志中收到以下错误。这曾经在几个月前起作用。

Caused by: java.lang.IncompatibleClassChangeError: class org.springframework.core.type.classreading.ClassMetadataReadingVisitor has interface org.springframework.asm.ClassVisitor as super class

引起:java.lang.IncompatibleClassChangeError: class org.springframework.core.type.classreading.ClassMetadataReadingVisitor 有接口 org.springframework.asm.ClassVisitor 作为超类

Please let me know if any pointers or if you guys need more information.

如果有任何指示或者你们需要更多信息,请告诉我。

采纳答案by Bhushan Bhangale

This error happens when the loaded class i.e. ClassMetadataReadingVisitordoes not respect the contract of inherited abstract class or interface i.e. ClassVisitor.

当加载的类 ieClassMetadataReadingVisitor不遵守继承的抽象类或接口 ie 的约定时会发生此错误ClassVisitor

Looks like at load time different versions of the above classes are getting loaded in your case.

看起来在加载时,您的情况正在加载上述类的不同版本。

Seems you have new spring-core jar and old spring-asm jar in your application. ClassMetadataReadingVisitorclass is getting loaded from spring-coreand ClassVisitorfrom spring-asm.

似乎您的应用程序中有新的 spring-core jar 和旧的 spring-asm jar。ClassMetadataReadingVisitor类正从加载弹簧核心ClassVisitor弹簧ASM

Please check using maven dependency:treecommand to see the dependent jars.

请使用 mavendependency:tree命令检查以查看依赖的 jar。

回答by Himanshu Bhardwaj

This error usually shows up when incomptiable versions of jars are used, for example spring-asmand spring-core. Have a look at forum.springsource.org/showthread.php?133341

当使用不可兼容版本的 jars 时,通常会出现此错误,例如spring-asmspring-core。看看forum.springsource.org/showthread.php?133341

回答by Alex Bretet

In spring version > 3.2.0, you no longer need to explicitly include spring-asmsince it has already been included in spring-core.

在 spring 版本 > 3.2.0 中,您不再需要显式包含,spring-asm因为它已经包含在spring-core.

Remove spring-asmfrom your build definition and ensure that spring-coreis there.

spring-asm从您的构建定义中删除并确保它spring-core在那里。

http://static.springsource.org/spring-framework/docs/current/spring-framework-reference/html/migration-3.2.html#migration-3.2-inline-asm

http://static.springsource.org/spring-framework/docs/current/spring-framework-reference/html/migration-3.2.html#migration-3.2-inline-asm

回答by Germán Acosta

I had the same problem and faced it by deleting my spring-data-jpadependency from pom.xml

我遇到了同样的问题,并通过spring-data-jpapom.xml

It's already included in the spring-coredependency.

它已经包含在spring-core依赖项中。

回答by Stewart

Update for those moving to versions above 3.1.x ... as made clear by this answer herethere is no longer a separate spring-asm, so it would be better to exclude spring-asmaltogether, once you're at Spring version 3.2.x

更新那些迁移到 3.1.x 以上版本的人......正如这里的答案所表明的那样,不再有单独的spring-asm,所以最好spring-asm完全排除,一旦你在 Spring 版本 3.2.x