融云与greenDao冲突解决办法

请尊重原创

在做即时通讯开发时,用融云来做,同时数据库使用了greenDao框架,那么问题来了,,融云内部内置了greenDao数据库,如果项目中再导入greenDao.jar包时,就会报错,解决办法是:去掉自己导入的greenDao.jar包,这个时候新问题又来了,那些使用greendao-generator自动生成的数据库文件全报错了,报错原因是构造方法不匹配。融云使用的文件加入了参数:tableName,但我们自动生成的没这个参数,修改方法就是:把报错的地方加上表名参数,一个一个的修改肯定不方便,其实,只要重新自动生成一遍就可以了,但这次生成方法不同,我们要修改下dao.ftl文件。ftl文件没见过?只要把greendao-generator.jar包解压出来,你就会找到,

/** * Properties of entity ${entity.className}.<br/> * Can be used for QueryBuilder and for referencing column names. */ public static class Properties {<#list entity.propertiesColumns as property> public final static Property ${property.propertyName?cap_first} = new Property(${property_index}, ${property.javaType}.class, "${property.propertyName}", ${property.primaryKey?string}, "${property.columnName}","${entity.tableName}");</#list> };

这里就是生成Properties类构造方法,我这里已经改好了,加入了:"${entity.tableName}" ,这个参数就是表名,默认的是没这个参数的

自动生成融云使用的数据库文件项目下载地址:

另外注意下:

public static void main(String[] args) throws Exception { Schema schema = new Schema(999, "com.it.bean");这里构造数据库版本时,如果版本号大于999时,生成的代码会在数字中,加入分隔符“,”,只要手动去掉这个符号就可以

明天是世上增值最快的一块土地,因它充满了希望

融云与greenDao冲突解决办法

相关文章:

你感兴趣的文章:

标签云: