1、错误描述
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlException at com.you.print.ExcelUtils.replaceModel(ExcelUtils.java:21) at com.you.print.TestReplaceExcel.main(TestReplaceExcel.java:28) Caused by: java.lang.ClassNotFoundException: org.apache.xmlbeans.XmlException 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) ... 2 more
2、错误原因
由错误提示可知,是缺少有关xmlbeans的jar
3、解决办法
(1)将xmlbeans-2.6.0.jar复制到lib目录下
(2)如果是maven项目,在pom.xml中添加
<!-- https://mvnrepository.com/artifact/org.apache.xmlbeans/xmlbeans --> <dependency> <groupId>org.apache.xmlbeans</groupId> <artifactId>xmlbeans</artifactId> <version>2.6.0</version> </dependency>