当前位置:网站首页>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 .
边栏推荐
- Codeforces Round #648 (Div. 2) E.Maximum Subsequence Value
- 图神经网络+对比学习,下一步去哪?
- Illustrated network: what is gateway load balancing protocol GLBP?
- Huber Loss
- uni-app 实现全局变量
- Add discount recharge and discount shadow ticket plug-ins to the resource realization applet
- The combination of deep learning model and wet experiment is expected to be used for metabolic flux analysis
- Node collaboration and publishing
- Applet (subcontracting)
- Use and programming method of ros-8 parameters
猜你喜欢

高性能Spark_transformation性能

Summary and Reflection on issues related to seq2seq, attention and transformer in hands-on deep learning

Introduction Guide to stereo vision (6): level constraints and polar correction of fusiello method

Ros-10 roslaunch summary

Ros-11 common visualization tools

Blogger article navigation (classified, real-time update, permanent top)

Generate confrontation network

Hosting environment API
![[beauty of algebra] singular value decomposition (SVD) and its application to linear least squares solution ax=b](/img/ee/8e07e2dd89bed63ff44400fe1864a9.jpg)
[beauty of algebra] singular value decomposition (SVD) and its application to linear least squares solution ax=b

Confusion matrix
随机推荐
Alibaba cloud sends SMS verification code
Rebuild my 3D world [open source] [serialization-1]
混淆矩阵(Confusion Matrix)
Return of missing persons
Applet network data request
12. Dynamic link library, DLL
浅谈Label Smoothing技术
利用请求头开发多端应用
C [essential skills] use of configurationmanager class (use of file app.config)
3D reconstruction open source code summary [keep updated]
Introduction Guide to stereo vision (6): level constraints and polar correction of fusiello method
Configuration and startup of kubedm series-02-kubelet
Codeforces Round #648 (Div. 2) D. Solve The Maze
C#图像差异对比:图像相减(指针法、高速)
L'information et l'entropie, tout ce que vous voulez savoir est ici.
Solution to the problem of the 10th Programming Competition (synchronized competition) of Harbin University of technology "Colin Minglun Cup"
顶会论文看图对比学习(GNN+CL)研究趋势
uni-app 实现全局变量
Introduction Guide to stereo vision (5): dual camera calibration [no more collection, I charge ~]
Characteristic Engineering