import java.util.HashMap; import java.util.Map; import org.apache.commons.beanutils.BeanUtils; import com.dss.mci.sys.entity.User; public class Test { public static void main(String[] args) throws Exception { // BeanUtils.populate(user,keyValues); map->bean Map<String, String> keyValues = new HashMap<>(); keyValues.put("userAccount", "ddd"); User user = new User(); // 将Map转化为User BeanUtils.populate(user, keyValues); System.out.println(user.getUserAccount()); Map<String, String> map = new HashMap<>(); // bean->map map = BeanUtils.describe(user); System.out.println(map.get("userAccount")); } }