0

有人告诉我 groovy xml 解析器更好更简单,我的问题是如何在 java 中使用 groovy 来解析 xml 文件并将其放入 pojo 对象中?谢谢。

4

1 回答 1

1

Groovy 编译器有一个称为“联合编译”的功能。用于用另一个 java 项目编译 groovy 项目。它在他们的网站中定义为

Joint compilation means that the Groovy compilation will parse the Groovy source files, create stubs for all of them, invoke the Java compiler to compile the stubs along with Java sources, and then continue compilation in the normal Groovy compiler way. This allows mixing of Java and Groovy files without constraint.

但问题是随着项目代码库的增加,它会导致静态引用出现一些问题。如果您使用 Maven 编译代码或使用 Ant 脚本,那么生活会变得更轻松。

参考链接: http: //groovy.codehaus.org/The+groovyc+Ant+Task

您还可以查看此链接http://today.java.net/pub/a/today/2004/08/12/groovyxml.html,其中用户尝试了很多选项,包括 Groovy。

于 2012-07-29T05:55:47.587 回答