The attribute name is not exit

com.jfinal.plugin.activerecord.ActiveRecordException: The model attribute XXX is not exists

生产环境的数据库忘记加了 XXX 字段 setXXX的时候报错 

然后加了字段 之后还报这个错 是要重启吗?为什么要重启才行

评论区

杜福忠

2020-08-11 12:23

因为DbKit:
private static Map<Class<? extends Model>, Config> modelToConfig

如果想改完数据库不重启就更新static Model字段,有好几种搞法,细腻一点的,可以搞一个控制器,然后请求执行刷新Model字段,Controller伪代码大致Action:
{
String tableName = get("tableName");
String className = get("className");
//String configName = get("configName");
List<Table> tableList = new ArrayList<Table>(1);
tableList.add(new Table(tableName, Class.forName(className)));
// DbKit.getConfig(configName)
new TableBuilder().build(tableList, DbKit.getConfig());
}
伪代码,没有测试,方向就是这个操作,可以试试

buerxuezai

2020-08-14 11:00

@杜福忠 谢谢 我去研究下

热门反馈

扫码入社