1. Map和Bean的相互转化

首先需要引入apache common beanutils maven依赖

<dependency>
	<groupId>commons-beanutils</groupId>
	<artifactId>commons-beanutils</artifactId>
	<version>1.9.2</version>
</dependency>

map2Bean

public static <T> T map2Bean(Map<String, ? extends Object> properties, Class<T> clazz) {
	if (CollectionUtils.isEmpty(properties)) {
		return null;
	}
	try {
		T newInstance = clazz.newInstance();
		BeanUtils.populate(newInstance, properties);
		return newInstance;
	} catch (Exception e) {
		logger.warn("", e);
		return null;
	}
}

bean2Map

public static <T> Map<?, ?> Bean2Map(T t) {
	return new BeanMap(t);
}