public static <T> List<T> getBeans(BeanFactory beanFactory, Class<T> requiredType) {
		if (!(beanFactory instanceof ListableBeanFactory)) {
			throw new RuntimeException("bean factory not support get list bean. factory type = " + beanFactory.getClass()
					.getName());
		}

		Map<String, T> beanMap = beansOfTypeIncludingAncestors((ListableBeanFactory) beanFactory, requiredType);
		return new ArrayList<>(beanMap.values());
	}
@Test
	public void testGetBeansIncludingAncestors() {
		DefaultListableBeanFactory parentBeanFactory = new DefaultListableBeanFactory();
		parentBeanFactory.registerBeanDefinition("foo", new RootBeanDefinition(Foo.class));

		DefaultListableBeanFactory childBeanFactory = new DefaultListableBeanFactory(parentBeanFactory);

		assertThat(childBeanFactory.getBeansOfType(Foo.class)).isEmpty();
		assertThat(BeanFactoryUtils.getBeans(childBeanFactory, Foo.class).size()).isEqualTo(1);
		assertThat(BeanFactoryUtils.getBeans(childBeanFactory, Bar.class)).isEmpty();

		MockBeanFactory mockBeanFactory = new MockBeanFactory();
		assertThatThrownBy(() -> BeanFactoryUtils.getBeans(mockBeanFactory, Bar.class))
				.isExactlyInstanceOf(RuntimeException.class)
				.hasMessageContaining("bean factory not support get list bean.");
	}