I ran into the same issue when watching Spring's YouTube seminar that used XML-based configuration. Of course, my solution is not ready for production and looks like a hack, but it solved my problem:
BeanDefinition beanDefinition; AnnotatedBeanDefinition annotatedBeanDefinition = (AnnotatedBeanDefinition) bd; StandardMethodMetadata factoryMethodMetadata = (StandardMethodMetadata) annotatedBeanDefinition.getFactoryMethodMetadata(); Class<?> originalClass = factoryMethodMetadata.getIntrospectedMethod().getReturnType();
Edit 1 It turns out that if you define your bean outside the configuration class using the stereotype annotation, everything will work fine:
@Configuration @ComponentScan(value = "foo.bar") public class Config {}
and
package foo.bar.model.impl @Component class FooImpl implements Foo {...}
source share