异常Exception in thread “main“ java.lang.NoClassDefFoundError: org/apache/poi/ooxml/POIXMLDocumentPart

解决异常Exception in thread "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

当java操作word或excel抛出这样的异常时,一般原型时pom文件少引入依赖

        
            org.apache.poi
            poi-ooxml
            4.1.0
        
        
            org.apache.poi
            poi
            4.1.2
        

pom文件需要添加以两个依赖即可解决bug

你可能感兴趣的:(技术交流)