java.lang.NoClassDefFoundError: org/apache/poi/poifs/filesystem/FileMagic

maven项目,使用POI读写2007版本Excel出错,一直不知道原因,后来发现导入的poi,和poi-ooxml版本不一致

Exception in thread "Thread-4" java.lang.NoClassDefFoundError: org/apache/poi/poifs/filesystem/FileMagic
	at org.apache.poi.openxml4j.opc.internal.ZipHelper.openZipStream(ZipHelper.java:208)
	at org.apache.poi.openxml4j.opc.ZipPackage.<init>(ZipPackage.java:98)
	at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:324)
	at org.apache.poi.util.PackageHelper.open(PackageHelper.java:37)
	at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:295)
	at main.App.readExcel(App.java:274)
	at main.App.lambda$actionPerformed$0(App.java:177)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: org.apache.poi.poifs.filesystem.FileMagic
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	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)
	... 8 more

pom文件poi配置

 <dependency>
      <groupId>org.apache.poi</groupId>
      <artifactId>poi</artifactId>
      <version>3.16</version>
</dependency>
<dependency>
       <groupId>org.apache.poi</groupId>
       <artifactId>poi-ooxml</artifactId>
       <version>3.17</version>
</dependency>

 

改为一样的版本就好了,如都用3.16

posted @ 2018-03-01 09:25  fengqixueluo  阅读(24897)  评论(1编辑  收藏  举报