JAXB XJC 可以禁止在生成的类中创建注释吗? [英] JAXB XJC Possible to suppress comment creation in generated classes?

查看:24
本文介绍了JAXB XJC 可以禁止在生成的类中创建注释吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的项目使用 XJC 从 XSD 生成 Java 类.我正在使用 JAVA EE 6.

Our project uses XJC to generate Java classes from an XSD. I'm using JAVA EE 6.

当我们拥有的所有 XSD 重新生成时,生成的类在文件顶部包含以下注释:

When all the XSDs we have are re-generated, the generated classes include this comment at the top of the file:

// Generated on: 2011.02.23 at 02:17:06 PM GMT 

是否可以取消此评论?原因是我们使用 SVN 进行版本控制,并且每次我们重新生成我们的类时,每个文件都会在 SVN 中显示为被更改,尽管唯一不同的是这条注释.因此,如果可能的话,我想完全删除评论.

Is it possible to suppress this comment? The reason is that we use SVN for version control, and every time we regenerate our classes, every single file shows as being changed in SVN, even though the only thing that differs is this comment. So I'd like to remove the comment altogether if possible.

有一个-no-header指令,但是我不想去掉整个header,让后人知道它是一个工具生成的文件,修改会覆盖.我只想删除时间戳.(或者,我会删除内置标题,然后以某种方式插入我自己的标题.)

There is a -no-header directive, but I don't want to remove the entire header, so that future generations know that it's a file generated from a tool, and that modifications will be overwritten. I only want to remove the timestamp. (Or alternatively, I'd remove the inbuilt header and then insert my own header somehow.)

推荐答案

如果无法使用选项,您可以自己对生成的文件进行后处理.对于一个非常具体的用例,我们必须在我们的项目中这样做......我们使用 Maven,并在生成 Java 类之后、编译并将它们打包到可分发的 JAR 之前执行特定的脚本.

If it's not possible using an option you can post-process the generated files yourself. For a very specific use-case we had to do it that way on our project... We use Maven and we execute a specific script after the Java classes have been generated and before we compile and package them to a distriuable JAR.

这篇关于JAXB XJC 可以禁止在生成的类中创建注释吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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