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

最近再测试使用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>
	

你可能感兴趣的:(java)