一、方式 代码生成器 & IDE 编译时代码生成: Pluggable Annotation Processing API 运行时代码生成: Compiler API 运行时生成字节码: cglib, javassist 二、辅助工具 String format tool 模板引擎: freemarker, velocity JavaPoet