场景
SpringBoot中使用POI实现Excel导入到数据库(图文教程已实践)
在进行解析Excel时提示:
Caused by: java.lang.NoSuchMethodError: org.apache.poi.util.POILogger.log(ILjava/lang/Object;)V
at org.apache.poi.openxml4j.opc.PackageRelationshipCollection.parseRelationshipsPart(PackageRelationshipCollection.java:304) ~[poi-ooxml-3.9.jar:3.9]
at org.apache.poi.openxml4j.opc.PackageRelationshipCollection.<init>(PackageRelationshipCollection.java:156) ~[poi-ooxml-3.9.jar:3.9]
at org.apache.poi.openxml4j.opc.PackageRelationshipCollection.<init>(PackageRelationshipCollection.java:124) ~[poi-ooxml-3.9.jar:3.9]
at org.apache.poi.openxml4j.opc.PackagePart.loadRelationships(PackagePart.java:559) ~[poi-ooxml-3.9.jar:3.9]
at org.apache.poi.openxml4j.opc.PackagePart.<init>(PackagePart.java:112) ~[poi-ooxml-3.9.jar:3.9]
at org.apache.poi.openxml4j.opc.PackagePart.<init>(PackagePart.java:83) ~[poi-ooxml-3.9.jar:3.9]
at org.apache.poi.openxml4j.opc.PackagePart.<init>(PackagePart.java:128) ~[poi-ooxml-3.9.jar:3.9]
at org.apache.poi.openxml4j.opc.ZipPackagePart.<init>(ZipPackagePart.java:78) ~[poi-ooxml-3.9.jar:3.9]
at org.apache.poi.openxml4j.opc.ZipPackage.getPartsImpl(ZipPackage.java:218) ~[poi-ooxml-3.9.jar:3.9]
at org.apache.poi.openxml4j.opc.OPCPackage.getParts(OPCPackage.java:662) ~[poi-ooxml-3.9.jar:3.9]
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:269) ~[poi-ooxml-3.9.jar:3.9]
at org.apache.poi.util.PackageHelper.open(PackageHelper.java:39) ~[poi-ooxml-3.9.jar:3.16]
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:204) ~[poi-ooxml-3.9.jar:3.9]
at com.ws.bus.sys.controller.WmsReceiveOrderController.parseExcel(WmsReceiveOrderController.java:206) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_112]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_112]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_112]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_112]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:209) ~[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136) ~[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
定位到出现错误的地方为:
解决
找到项目的pom.xml部分
项目所需依赖为:
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>3.9</version>
</dependency>
但是除此之外还导入了一个
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.16</version>
</dependency>
导致版本冲突。
标签:POILogger,java,log,jar,poi,apache,org,3.9 From: https://blog.51cto.com/BADAOLIUMANGQZ/6147611