修改getPropertySimpleType方法实现,不再使用Class.forName(str), 防止出现找不到类的问题。

This commit is contained in:
zack 2023-07-25 22:48:47 +08:00
parent 91e503ba74
commit 3247658ded
2 changed files with 16 additions and 10 deletions

View File

@ -99,17 +99,13 @@ public class Column {
} }
public String getPropertySimpleType() { public String getPropertySimpleType() {
try { if (columnConfig.getPropertyType() != null) {
if (columnConfig.getPropertyType() != null) { if (!columnConfig.getPropertyType().contains(".")) {
if (!columnConfig.getPropertyType().contains(".")) { return columnConfig.getPropertyType();
return columnConfig.getPropertyType();
}
return Class.forName(columnConfig.getPropertyType()).getSimpleName();
} else {
return propertyType.substring(propertyType.lastIndexOf(".") + 1);
} }
} catch (Throwable e) { return StringUtil.substringAfterLast(columnConfig.getPropertyType(), ".");
throw new RuntimeException(e); } else {
return StringUtil.substringAfterLast(propertyType, ".");
} }
} }

View File

@ -287,5 +287,15 @@ public class StringUtil {
return string != null ? string.trim() : null; return string != null ? string.trim() : null;
} }
public static String substringAfterLast(String text, String str) {
if (text == null) {
return null;
}
if (str == null) {
return text;
}
return text.substring(text.lastIndexOf(str) + 1);
}
} }