public static <T> T getProperty(Object bean, String name, Class<T> clazz) throws Exception {
        Method method = ReflectUtils.getPropertyGetterMethod(bean.getClass(), name);
        if (method.isAccessible()) {
            return (T) method.invoke(bean);
        } else {
            try {
                method.setAccessible(true);
                return (T) method.invoke(bean);
            } finally {
                method.setAccessible(false);
            }
        }
    }
@Test
    public void testGetProperty() throws Exception {
        TestBean config = new TestBean();
        config.setAlias("1111aaaa");
        config.setHeartbeat(2000);
        config.setRegister(false);
        Assert.assertEquals(BeanUtils.getProperty(config, "alias", String.class), "1111aaaa");
        Assert.assertTrue(BeanUtils.getProperty(config, "heartbeat", int.class) == 2000);
        Assert.assertTrue((Integer) BeanUtils.getProperty(config, "heartbeat", null) == 2000);
        Assert.assertFalse(BeanUtils.getProperty(config, "register", boolean.class));
        boolean error = false;
        try {
            BeanUtils.getProperty(config, "xxx", String.class);
        } catch (Exception e) {
            error = true;
        }
        Assert.assertTrue(error);
    }