Config:
@Override public void configPlugin(Plugins me) { // DruidPlugin druidPlugin = new DruidPlugin("jdbc:mysql://localhost/bet_flow?serverTimezone=UTC", "root", "1234"); // C3p0Plugin c3p0Plugin = new C3p0Plugin("jdbc:mysql://localhost/bet_flow?serverTimezone=UTC", "root", "1234"); DruidPlugin druidPlugin = new DruidPlugin(p.get("jdbcUrl"), p.get("user"), p.get("password").trim()); me.add(druidPlugin); ActiveRecordPlugin arp = new ActiveRecordPlugin(druidPlugin); arp.setShowSql(true); arp.setDialect(new MysqlDialect()); _MappingKit.mapping(arp); me.add(arp); }
Main:
public static void main(String[] args) { UndertowServer.start(BetFlowConfig.class, 80, true); new User().set("id",1).set("name", "James").save(); }
异常:
Exception in thread "main" java.lang.NullPointerException
at com.jfinal.plugin.activerecord.Model.save(Model.java:542)
at cn.yangchaojie.BetFlowApplication.main(BetFlowApplication.java:21)
报错源码:
public boolean save() { filter(FILTER_BY_SAVE); Config config = _getConfig(); Table table = _getTable(); StringBuilder sql = new StringBuilder(); List<Object> paras = new ArrayList<Object>(); config.dialect.forModelSave(table, attrs, sql, paras); // 这里报错 // if (paras.size() == 0) return false; // The sql "insert into tableName() values()" works fine, so delete this line
请问是什么原因?
项目:JFinal