java使cxfcodegenplugin生成的类能够持久化
我有一个Maven jar项目,它使用cxf codegen插件创建了一个SOAP客户端
在另一个使用该客户机的Maven项目中,只需使用JPA(当前使用OpenJPA),将cxf codegen插件生成的数据类(一些soap响应)的实例持久化即可
在编译/增强和安装客户机jar之前,在每次生成客户机源代码之后,使用一些配置工具(例如)可能会向数据类添加@Entity注释,但我希望在尽可能保持客户机通用性的同时,摆脱这个阶段。使用客户机的项目应该能够安全地假设类具有持久性
处理这个问题的最佳方法可能是在客户端项目设置中使用一些技巧(目前正在使用openjpa maven插件来增强数据类)来检测所需的类,并以某种方式使它们具有持久性功能,同时增强这些类
我宁愿跳过保养豆子之类的事情。xml和注释(如果可能的话),但这也是一种选择
# 1 楼答案
如果有人需要同样的方法,我会描述我目前使用的方法。它基于添加注释,使用
com.google.code.maven-replacer-plugin
添加id
和imports
等字段简而言之:我在我的^{中添加了以下内容
为了使代码保持良好的格式,所有缩进和换行都需要在
<replacement>
中。使用regexps可能会更时髦,但这对我来说已经足够好了