简体   繁体   English

如何解析groovy中的xml文件并将其放在pojo中?

[英]How parse xml file in groovy and put it in a pojo?

Someone told me that groovy xml parser is better and easy, my question how to use groovy inside java to parse an xml file and put it in a pojo object ? 有人告诉我groovy xml解析器更好,更简单,我的问题是如何在Java中使用groovy解析xml文件并将其放在pojo对象中? thanks. 谢谢。

Groovy compiler has a feature called "joint-compilation". Groovy编译器具有称为“联合编译”的功能。 That is used for compiling groovy project with another java project. 这用于与另一个java项目一起编译groovy项目。 It is defined in their site as 在他们的网站中定义为

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.

But the catch is as your project's codebase increases, it causes some problems with static references. 但是要注意的是,随着项目代码库的增加,它会导致静态引用出现一些问题。 If you are compiling your code using Maven or use Ant scripts then life becomes easier. 如果您使用Maven或Ant脚本来编译代码,那么生活会变得更加轻松。

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

You could also look into this link http://today.java.net/pub/a/today/2004/08/12/groovyxml.html where the user has tried a lot of options including Groovy. 您还可以查看此链接http://today.java.net/pub/a/today/2004/08/12/groovyxml.html ,其中用户尝试了很多选项,包括Groovy。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM