@JFinal 按照我的理解,写了下面的代码,不过好像不对……我想让Generator生成的baseModel都继承自我自定义的commonModel ^_^ 该怎么写呀?
package baseModel; import com.jfinal.plugin.activerecord.generator.BaseModelGenerator; import com.jfinal.plugin.activerecord.generator.TableMeta; public class ResetBaseModelGenerator extends BaseModelGenerator { protected String classDefineTemplate = "/**%n" + " * Generated by JFinal, do not modify this file.%n" + " */%n" + "@SuppressWarnings(\"serial\")%n" + "public abstract class %s<M extends %s<M>> extends CommonModel<M> implements IBean {%n%n"; public ResetBaseModelGenerator(String baseModelPackageName, String baseModelOutputDir) { super(baseModelPackageName, baseModelOutputDir); // TODO Auto-generated constructor stub } protected void genClassDefine(TableMeta tableMeta, StringBuilder ret) { ret.append(String.format(classDefineTemplate, tableMeta.baseModelName, tableMeta.baseModelName)); } }
项目:JFinal
1:原来的 classDefineTemplate 中是 extends Model,改成 extends CommonModel
2:让 CommonModel 继承 Model
3:使用生成器时注入:generator.setBaseModelGenerator(new ResetBaseModelGenerator())