Maven缺少依赖:java.lang.ClassNotFoundException: org.apache.poi.openxml4j.exceptions.InvalidFormatExcepti
程序员文章站
2022-04-26 15:57:16
...
1.报错描述
运行IpHelper类的时候,报错:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/poi/openxml4j/exceptions/InvalidFormatException
at com.ggstar.util.ip.IpHelper.getRegionRelationMap(IpHelper.java:88)
at com.ggstar.util.ip.IpHelper.getIpRelation(IpHelper.java:58)
at com.ggstar.util.ip.IpHelper.buildTrain(IpHelper.java:33)
at com.ggstar.util.ip.IpHelper.<clinit>(IpHelper.java:27)
at _1005SparkSQLproject.Log.IpUtils$.getCity(IpUtils.scala:12)
at _1005SparkSQLproject.Log.IpUtils$.main(IpUtils.scala:16)
at _1005SparkSQLproject.Log.IpUtils.main(IpUtils.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: java.lang.ClassNotFoundException: org.apache.poi.openxml4j.exceptions.InvalidFormatException
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 12 more
2.原因
缺少pom依赖。
3.添加对应依赖
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.14</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.14</version>
</dependency>
上一篇: pom.xml报错
下一篇: Maven项目中POM文件的详解