代码
/** * 获取注解字段信息 * @param object 实体对象 * @param methodName 方法名 * @param defaultValue 默认值 * @return 返回 Object */public staticObject getFieldValue(T object, String methodName, String defaultValue) { if (object != null && methodName != null) { try { Class currClass = object.getClass(); Method method = currClass.getDeclaredMethod(methodName); Object value = method.invoke(object); if (value instanceof String && StringUtils.isEmpty(value)) return defaultValue; return value; } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { log.error("", e); } } return defaultValue;}