导出Excel过程中遇到的问题java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlException

尝试实现java导出功能时遇到如下报错:

org.apache.jasper.JasperException: javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlException

经查询,得知是缺某版本的xmlbean.jar

官方网站:http://xmlbeans.apache.org/

所有的下载链接最终都指向了http://attic.apache.org/projects/xmlbeans.html

然后指向了

http://archive.apache.org/dist/xml/xmlbeans/

页面上方有

● the XMLbeans project page

● the XMLbeans download page

● the XMLbeans download area

● the XML/xmlbeans archive

这样的四个链接

第一个是官网

第二个是下载页,指出Current release: 2.4.0 released on July 8, 2008.最新版本是2008年的2.4,而其官网上是2.6

往下看,有这样一句

Binary or source?

Most users will want to download a binary release of XMLBeans. If you're interested in contributing or like to live on the bleeding edge, you may want to compile the source for yourself.

点那个链接,会跳到apache的镜像网站列表

第一项:http://mirrors.shuosc.org/apache/xmlbeans/binaries

apache官方推荐的,点击以后,404。

第二条是:http://mirrors.shuosc.org/apache/xmlbeans/binaries

点击后跳转到http://attic.apache.org/projects/xmlbeans.html

页面上有一些文字,告诉你apache xmlbean从2013年开始,移到了attic,右侧有一堆各种项目,往下找,找到xmlbean,点完以后,会回到顶部。

仔细看文字中的链接,Apache XMLBeans是官方网站,第二个链接http://xmlbeans.apache.org ,也是官方网站,第三个链接Apache Archives.,是Apache的目录列表

● the XMLbeans project page

● the XMLbeans download page

● the XMLbeans download area

● the XML/xmlbeans archive

是不是似曾相识,对,就在本页面的上方。循环开始。我们是从第二项XMLbeans download page开始进入的,下面来看第三项,第三项是目录列表,秘密就在这里,下面的xmlbeans-current.zip就是最新版本,但是鉴于官网写的是2.6,这个名字还是感觉不怎么靠谱,就继续找,我们来看第二个目录,binaries/,点击,1.0以后的版本都在这里,往下翻,一直找到xmlbeans-2.6.0.zip,成功。从时间看来,确实就是上一级目录的xmlbeans-current.zip,一样的。

下载后,把xmlbeans-2.6.0\lib中的jar复制到运行目录下的lib下,我这里是WebContent\WEB-INF\lib,不必在eclipse中导入