<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.8</version>
</dependency>
/**
* @Description: 将数据转换到相应的容器
* @return
* @throws
*/
public static <T> T convertValue(Object bean, Class<T> clazz){
try{
ObjectMapper mapper = new ObjectMapper();
return mapper.convertValue(bean, clazz);
}catch(Exception e){
logger.error("错误的转换:BeanUtil.convertValue() --->" + e.getMessage());
return null;
}
}