Java code generation

筅森魡賤 提交于 2019-12-07 08:12:36

问题


I am looking for nice (java) code generation engine. I have found cglib but it is very poorly documented and I am not quite sure that it can generate actual java classes (files) and only dynamic classes. If I am wrong maybe someone knows has a link with an example.

Roman


回答1:


Have a look at codemodel, used with success for my projects.




回答2:


Didn't really try, but you may want to take a look at another code generation Java framework called Javassist, which also has pretty thorough tutorial. Also Hibernate changed code generation framework from cglib to javassist. Quote, explaining why:

The simple fact of the matter is that development on CGLIB has largely stopped. It happens. Developers for whatever reason (the reasons are their own) move on to new priorities.

Source




回答3:


I just released cgV19 here: https://github.com/carstenSpraener/cgV19 it's based on a code generator i wrote in 2002 to 2006 and which is still in production use. cgV19 is a re implementation with lessons learned. It has:

  • Support for gradle
  • Uses Groovy as a template language
  • a modular "cartridge" system to add several generator for different aspects
  • small footprint

Just try it out and give me feedback would be very nice.



来源:https://stackoverflow.com/questions/6973580/java-code-generation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!