for (Field field : object.getClass().getDeclaredFields()) { try { AccessController.doPrivileged(PrivilegedAction() -> { ReflectionUtils.makeAccessible(field); // 通过反射类机制确定字段属性是否可获取,获取之后关闭可见性开关 return null; }); ExcelProperty annotation = field.getAnnatation(ExcelProperty.class); if (annotation.index() == firstColumnIndex) { fieldValue = field.get(object); break; } } catch (illegalAccessException e) { throw new ServiceException("解析数据时发生异常:" + e.getMessage()); } }
ReflectionUtils.makeAccessible(field); // 通过反射类机制确定字段属性是否可获取,获取之后关闭可见性开关
浙公网安备 33010602011771号