当前位置:网站首页>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 .
边栏推荐
- [code practice] [stereo matching series] Classic ad census: (5) scan line optimization
- C form click event did not respond
- Applet data attribute method
- 2311. Longest binary subsequence less than or equal to K
- 520 diamond Championship 7-4 7-7 solution
- Introduction Guide to stereo vision (5): dual camera calibration [no more collection, I charge ~]
- 牛顿迭代法(解非线性方程)
- 12. Dynamic link library, DLL
- c#比较两张图像的差异
- Illustrated network: what is gateway load balancing protocol GLBP?
猜你喜欢
RT thread kernel quick start, kernel implementation and application development learning with notes
c语言指针深入理解
Wxml template syntax
TF coordinate transformation of common components of ros-9 ROS
【ManageEngine】如何利用好OpManager的报表功能
Hi Fun Summer, play SQL planner with starrocks!
Priority queue (heap)
Information and entropy, all you want to know is here
fs. Path module
nodejs_ fs. writeFile
随机推荐
Uni app implements global variables
np. allclose
Node collaboration and publishing
混淆矩阵(Confusion Matrix)
利用请求头开发多端应用
Codeworks round 639 (Div. 2) cute new problem solution
Huber Loss
scipy. misc. imread()
高性能Spark_transformation性能
Can't find the activitymainbinding class? The pit I stepped on when I just learned databinding
C#图像差异对比:图像相减(指针法、高速)
AUTOSAR from getting started to mastering 100 lectures (103) -dbc file format and creation details
Global configuration tabbar
Introduction Guide to stereo vision (1): coordinate system and camera parameters
Understanding rotation matrix R from the perspective of base transformation
Introduction Guide to stereo vision (5): dual camera calibration [no more collection, I charge ~]
Ros-11 common visualization tools
[beauty of algebra] solution method of linear equations ax=0
Driver's license physical examination hospital (114-2 hang up the corresponding hospital driver physical examination)
【阅读笔记】图对比学习 GNN+CL