简体   繁体   English

是否有Maven插件可基于休眠实体XML生成Java源代码(实体)类?

[英]Are there maven plugins to generate java source code (entity) classes based on a hibernate entity XML?

I want to automate java source code generation through a maven java source code generator. 我想通过Maven Java源代码生成器自动化Java源代码生成。 I want to create entity classes by looking at an one big entity xml file which will have all the entities and entity relationships in a system. 我想通过查看一个大的实体xml文件来创建实体类,该文件将具有系统中的所有实体和实体关系。 as far as I searched there is no such plug-in in maven for the moment. 据我搜索,目前在maven中还没有这样的插件。

do I have to write my own mojo to get this done? 我必须编写自己的Mojo才能完成此工作吗?

any ideas and directions to follow will be relay appreciated. 任何想法和遵循的方向将继续受到赞赏。

Did you try this plugin : http://mojo.codehaus.org/maven-hibernate3/hibernate3-maven-plugin/hbm2java-mojo.html 您是否尝试过此插件: http : //mojo.codehaus.org/maven-hibernate3/hibernate3-maven-plugin/hbm2java-mojo.html

The hbm2java goal should be what you are looking for. hbm2java目标应该是您想要的。

If you use Eclipse or NetBeans they both have a tool to generate entity classes directly from database tables. 如果使用Eclipse或NetBeans,则它们都具有直接从数据库表生成实体类的工具。

You would not even need to provide the XML definitions. 您甚至不需要提供XML定义。

There are several plugins which do code generation, but it is always a custom task, eg there are plugins to generate web service classes from WSDL file, or I've used querydsl's generator for query-objects. 有几个插件可以执行代码生成,但这始终是一个自定义任务,例如,有一些插件可以从WSDL文件生成Web服务类,或者我已经使用querydsl的生成器来生成查询对象。

So, first of all, decide if you are not reinventing a wheel and there are some similar projects which do what you want. 因此,首先,确定您是否没有重新发明轮子,并且有一些类似的项目可以满足您的需求。 It it is not a case, take any plugin which does something similar and write your own for your situation. 情况并非如此,请使用任何类似的插件并根据情况编写自己的插件。

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

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