当前位置:网站首页>Greendao reported an error in qigsaw, could not init daoconfig
Greendao reported an error in qigsaw, could not init daoconfig
2022-07-05 09:15:00 【Xu Jiajia 233】
Report errors
org.greenrobot.greendao.DaoException: Could not init DAOConfig
scene
- Use qigsaw
- The host module depends on greenDAO
- The plug-in module uses greenDAO
- The plug-in module uses greenDAO Report errors :Could not init DAOConfig
reason
- greenDAO The source code calls through reflection Properties class
- Host module loading greenDAO Of ClassLoader yes PathClassLoader
- Plug in module loading AbstractDao Implementation class ClassLoader yes QigsawClassLoader
- because QigsawClassLoader Not loaded in DAOConfig, So it will report an error .
How to check it out
The way to check is to check greenDAO Source code , The crash caused by plug-in , So it can be quickly inferred that ClassLoader The problem of , After verification, it was found that .
public DaoConfig(Database db, Class<? extends AbstractDao<?, ?>> daoClass) {
this.db = db;
try {
this.tablename = (String) daoClass.getField("TABLENAME").get(null);
Property[] properties = reflectProperties(daoClass);
this.properties = properties;
allColumns = new String[properties.length];
List<String> pkColumnList = new ArrayList<String>();
List<String> nonPkColumnList = new ArrayList<String>();
Property lastPkProperty = null;
for (int i = 0; i < properties.length; i++) {
Property property = properties[i];
String name = property.columnName;
allColumns[i] = name;
if (property.primaryKey) {
pkColumnList.add(name);
lastPkProperty = property;
} else {
nonPkColumnList.add(name);
}
}
String[] nonPkColumnsArray = new String[nonPkColumnList.size()];
nonPkColumns = nonPkColumnList.toArray(nonPkColumnsArray);
String[] pkColumnsArray = new String[pkColumnList.size()];
pkColumns = pkColumnList.toArray(pkColumnsArray);
pkProperty = pkColumns.length == 1 ? lastPkProperty : null;
statements = new TableStatements(db, tablename, allColumns, pkColumns);
if (pkProperty != null) {
Class<?> type = pkProperty.type;
keyIsNumeric = type.equals(long.class) || type.equals(Long.class) || type.equals(int.class)
|| type.equals(Integer.class) || type.equals(short.class) || type.equals(Short.class)
|| type.equals(byte.class) || type.equals(Byte.class);
} else {
keyIsNumeric = false;
}
} catch (Exception e) {
throw new DaoException("Could not init DAOConfig", e);
}
}
private static Property[] reflectProperties(Class<? extends AbstractDao<?, ?>> daoClass)
throws ClassNotFoundException, IllegalArgumentException, IllegalAccessException {
Class<?> propertiesClass = Class.forName(daoClass.getName() + "$Properties");
Field[] fields = propertiesClass.getDeclaredFields();
ArrayList<Property> propertyList = new ArrayList<Property>();
final int modifierMask = Modifier.STATIC | Modifier.PUBLIC;
for (Field field : fields) {
// There might be other fields introduced by some tools, just ignore them (see issue #28)
if ((field.getModifiers() & modifierMask) == modifierMask) {
Object fieldValue = field.get(null);
if (fieldValue instanceof Property) {
propertyList.add((Property) fieldValue);
}
}
}
Property[] properties = new Property[propertyList.size()];
for (Property property : propertyList) {
if (properties[property.ordinal] != null) {
throw new DaoException("Duplicate property ordinals");
}
properties[property.ordinal] = property;
}
return properties;
}
Solution
There are still many solutions , Mainly based on business needs . The author will write some possible solutions :
- Add the plug-in to the greenDAO The relevant logic of is put into the host module
- If in the plug-in greenDAO There is not much logic in , As a temporary solution , Can be greenDAO The called class is defined again in the host .( It can only be a temporary plan )
- If not used in the host greenDao The logic of , It can be changed into a plug-in that directly depends on , Instead of loading in the host .
边栏推荐
- notepad++
- 【ManageEngine】如何利用好OpManager的报表功能
- Pearson correlation coefficient
- scipy.misc.imread()
- My life
- Rebuild my 3D world [open source] [serialization-3] [comparison between colmap and openmvg]
- AUTOSAR from getting started to mastering 100 lectures (103) -dbc file format and creation details
- Characteristic Engineering
- 生成对抗网络
- TF coordinate transformation of common components of ros-9 ROS
猜你喜欢
[technical school] spatial accuracy of binocular stereo vision system: accurate quantitative analysis
TF coordinate transformation of common components of ros-9 ROS
高性能Spark_transformation性能
2020 "Lenovo Cup" National College programming online Invitational Competition and the third Shanghai University of technology programming competition
Rebuild my 3D world [open source] [serialization-3] [comparison between colmap and openmvg]
Information and entropy, all you want to know is here
Applet (subcontracting)
[beauty of algebra] singular value decomposition (SVD) and its application to linear least squares solution ax=b
Applet global style configuration window
My experience from technology to product manager
随机推荐
Solution to the problems of the 17th Zhejiang University City College Program Design Competition (synchronized competition)
一题多解,ASP.NET Core应用启动初始化的N种方案[上篇]
Applet (use of NPM package)
利用请求头开发多端应用
c语言指针深入理解
Chris LATTNER, the father of llvm: why should we rebuild AI infrastructure software
一题多解,ASP.NET Core应用启动初始化的N种方案[上篇]
Hi Fun Summer, play SQL planner with starrocks!
[beauty of algebra] solution method of linear equations ax=0
Applet (global data sharing)
Transfer learning and domain adaptation
信息与熵,你想知道的都在这里了
迁移学习和域自适应
Golang foundation - the time data inserted by golang into MySQL is inconsistent with the local time
L'information et l'entropie, tout ce que vous voulez savoir est ici.
Mengxin summary of LCs (longest identical subsequence) topics
2310. The number of bits is the sum of integers of K
Nodemon installation and use
Confusing basic concepts member variables local variables global variables
Hosting environment API