BeanUtils之对象实体类转HashMap
package com.example.demo.common.Utils;
import org.apache.catalina.util.Introspection;
import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
// 实体工具类
public class BeanUtils {
public static Map beanToMap(Object bean) throws InvocationTargetException, IntrospectionException, IllegalAccessException {
Map retrunMap = new HashMap<>();
BeanInfo beanInfo = Introspector.getBeanInfo(bean.getClass());
PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
for (int i=0;i 


