如何让 Apache POI 和 JAXB 协同工作? [英] How do I get Apache POI and JAXB to work together?

查看:36
本文介绍了如何让 Apache POI 和 JAXB 协同工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

java.lang.ClassNotFoundException: org.apache.xmlbeans.XmlObject

我在运行代码时遇到该错误.好的,没关系 - 我只是忘记获取 XMLBeans ......但它已经退役,我在他们的档案中找不到最新版本.所以我发现 JAXB 可以是一个替代方案,我下载了它并尝试将 jar 文件添加到我在 Intellij 中的库中,但我仍然在查找 XMLBeans 依赖项时遇到相同的错误.

I get that error when I run my code. Ok, that's fine - I just forgot to get XMLBeans... but it's been retired and I can't find a recent version in their archives. So I found that JAXB can be an alternative, I downloaded it and tried adding the jar files to my library in Intellij, but I still get the same error looking for the XMLBeans dependency.

如何让 Apache POI 使用 JAXB 代替 XMLBeans?为什么 JAXB 有 7 个不同的 jar 文件,而我不知道它们中的任何一个是做什么的?我只想处理一些 excel 文件,而不是大肆追逐:(

How do I get Apache POI to use JAXB in place of XMLBeans? Why does JAXB have like 7 different jar files and I can't find out what any of them do? I just want to work on some excel files and not go on a wild goose chase :(

推荐答案

XMLBeans 是 Apache POI 的一个依赖项,POI 不会在它的位置使用不同的库.XMLBeans 打包在我检查过的 Apache POI 下载中,因此您应该可以使用它.您只需要在运行应用程序时确保 xmlbeans jar 文件在 java 类路径中即可.

XMLBeans is a dependency of Apache POI and POI won't use a different library in it's place. XMLBeans comes packaged in the Apache POI downloads which I have checked, so you should have it available to you. You just need to ensure the xmlbeans jar file is in the java classpath when running your application.

我检查了 http://poi.apache.org/download.html#POI-3.14,解压压缩的tar存档(我用的是7-Zip),你会发现xmlbeans-2.6.0.poi-3.14/ooxml-lib目录下的jar包.

I have checked the latest POI binary tar.gz file 'poi-bin-3.14.tar.gz' available from http://poi.apache.org/download.html#POI-3.14, extracting the compressed tar archive (I use 7-Zip), you will find xmlbeans-2.6.0.jar in the poi-3.14/ooxml-lib directory.

这篇关于如何让 Apache POI 和 JAXB 协同工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆