项目报错显示:class net.sf.cglib.core.DebuggingClassWriter has interface org.objectweb.asm.ClassVisitor

java 专栏收录该内容
13 篇文章 0 订阅

最近再测试使用easyexcel导入excel时,发现了一个问题:使用CGLib实现动态代理时出现了下面这个错误。

Exception in thread "main" java.lang.IncompatibleClassChangeError: class net.sf.cglib.core.DebuggingClassWriter has interface org.objectweb.asm.ClassVisitor as super class
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at net.sf.cglib.core.DefaultGeneratorStrategy.getClassVisitor(DefaultGeneratorStrategy.java:30)
	at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:24)
	at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
	at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:144)
	at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:116)
	at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108)
	at net.sf.cglib.beans.BeanMap$Generator.<clinit>(BeanMap.java:64)
	at net.sf.cglib.beans.BeanMap.create(BeanMap.java:56)
	at com.alibaba.excel.modelbuild.ModelBuildEventListener.buildUserModel(ModelBuildEventListener.java:35)
	at com.alibaba.excel.modelbuild.ModelBuildEventListener.invoke(ModelBuildEventListener.java:21)
	at com.alibaba.excel.analysis.BaseSaxAnalyser.notifyListeners(BaseSaxAnalyser.java:72)
	at com.alibaba.excel.analysis.v07.XlsxRowHandler.endRow(XlsxRowHandler.java:132)
	at com.alibaba.excel.analysis.v07.XlsxRowHandler.endElement(XlsxRowHandler.java:110)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:609)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1782)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2967)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:602)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:505)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:841)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:770)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
	at com.alibaba.excel.analysis.v07.XlsxSaxAnalyser.parseXmlSource(XlsxSaxAnalyser.java:97)
	at com.alibaba.excel.analysis.v07.XlsxSaxAnalyser.execute(XlsxSaxAnalyser.java:74)
	at com.alibaba.excel.analysis.ExcelAnalyserImpl.analysis(ExcelAnalyserImpl.java:74)
	at com.alibaba.excel.analysis.ExcelAnalyserImpl.analysis(ExcelAnalyserImpl.java:67)
	at com.alibaba.excel.ExcelReader.read(ExcelReader.java:112)
	at com.aaa.project.tool.easyExcel.ExcelUtils.readExcel(ExcelUtils.java:32)
	at com.aaa.project.tool.easyExcel.ExcelUtils.main(ExcelUtils.java:85)

后面发现是因为两个相关的jar包(cglib和asm的版本冲突了)
在这里插入图片描述
解决方法:将cglib 3.1 换成cglib 2.2 或是将asm 3.1 换成 asm 2.2.3 便可解决此问题,该版本中的DebuggingClassWriter的父类为ClassWriter

		<dependency>
			<groupId>cglib</groupId>
			<artifactId>cglib</artifactId>
			<version>2.2.2</version>
		</dependency>
		
	<!-- 或是 -->
	
		<dependency>
			<groupId>asm</groupId>
			<artifactId>asm</artifactId>
			<version>2.2.3</version>
		</dependency>
	
  • 3
    点赞
  • 0
    评论
  • 4
    收藏
  • 打赏
    打赏
  • 扫一扫,分享海报

参与评论
请先登录 后发表评论~
©️2021 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页

打赏作者

SJH100%

你的鼓励将是我创作的最大动力

¥2 ¥4 ¥6 ¥10 ¥20
输入1-500的整数
余额支付 (余额:-- )
扫码支付
扫码支付:¥2
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值