既然 XMLBeans 已经停用,应该使用什么来代替它呢?

What to use instead of XMLBeans now that it has been retired?

我正在开始一个有第三方 XSD 的新项目。我的 Java 应用程序需要生成和读取符合此 XSD 的 XML 消息。过去我为此使用 Apache XMLBeans 。看起来 XMLBeans 已经退休了。

既然 XMLBeans 已经停用,那么什么是它的良好替代品?我在其他项目中使用过 XStream,但我不记得 XStream 能够从 XSD 生成 Java 类,所以我认为对于这个用例,它不是 XMLBeans 的好选择。我在 XSD 中定义了数百种类型,我真的不想手动创建数百个 Java 类来用 Java 表示它们。

换句话说,使用 XStream example,我在 XSD 中定义了一个 Person 类型(以及其他 99 个)。使用 XMLBeans 我可以生成 Java 类来表示这些对象,但是使用 XStream 我需要手动或使用其他工具创建 Java 类 (e.g. Person)。在这种情况下我应该使用什么工具?

您看过 JAXB 了吗?我没有对其中任何一个进行任何操作,但是通过谷歌搜索 "alternative to XMLBeans" 可以找到很多对此包的引用。这是一篇比较它们的文章...

http://blog.bdoughan.com/2012/01/how-does-jaxb-compare-to-xmlbeans.html

XMLBeans 已经 未退休 :

The Apache POI project has unretired the XMLBeans codebase and is maintaining it as a sub-project. Until now the XMLBeans codebase was held in the Apache Attic where former Apache projects are kept for the public good.

截至 2020 年 8 月的最新版本是:

3.1.0 (March 26, 2019)

话虽如此,但根据它的退役历史,我不确定我会推荐使用它。其他解决方案,例如 JAXB,可能是首选,因为它可能会在未来得到更好的维护。