Solve unusual Exception in the thread “is the main” Java. Lang. NoClassDefFoundError: org/apache poi/ooxml/POIXMLDocumentPart

Exception in thread “main” java.lang.NoClassDefFoundError: org/apache/poi/ooxml/POIXMLDocumentPart at com.deepoove.poi.XWPFTemplate.compile(XWPFTemplate.java:108) at com.deepoove.poi.XWPFTemplate.compile(XWPFTemplate.java:90) at com.deepoove.poi.XWPFTemplate.compile(XWPFTemplate.java:77) at com.deepoove.poi.XWPFTemplate.compile(XWPFTemplate.java:73) at com.sun.unifyspatialdatabase.utils.WordTest.test(WordTest.java:33) at com.sun.unifyspatialdatabase.utils.WordTest.main(WordTest.java:46) Caused by: java.lang.ClassNotFoundException: org.apache.poi.ooxml.POIXMLDocumentPart at java.net.URLClassLoader.findClass(URLClassLoader.java:382) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) … 6 more

When A Java operation on Word or Excel throws such an exception, the general prototype poM file introduces fewer dependencies

<dependency> <groupId>org.apache.poi</groupId> <artifactId> Poi-ooxml </artifactId> <version>4.1.0</version> </dependency> <dependency> <groupId>org.apache. Poi </groupId> <artifactId>poi</artifactId> <version>4.1.2</version> </dependency>Copy the code

Pom files need to be added with two dependencies to solve the bug