The FactoryBean.OBJECT_TYPE_ATTRIBUTE can be used to give type information to a FactoryBean. The documentation isn't clear about what types can be used.

Both Spring Boot and Feign have used String values. It appears that in reality only Class and ResolvableType are supported.

Should AbstractBeanFactory also accept String values containing class names? Or should the types supported be documented in FactoryBean.OBJECT_TYPE_ATTRIBUTE? If String types are not supported, the openfeign code should probably change.

Comment From: wilkinsona

Spring Data also uses a String value.

Comment From: snicoll

I thought they would have removed it with the change to specify the targetType (the line above in your link). Ping @mp911de

Irrespective of this issue, setTargetType is a better candidate for letting the container know about the type of the bean.

Comment From: mp911de

FWIW, Spring Data sets a Class object for FactoryBean.OBJECT_TYPE_ATTRIBUTE. We could remove the attribute as we set the targetType as well.

Comment From: wilkinsona

Sorry for the confusion. There are two usages in Spring Data and I evidently linked to the wrong one. This is where a String is used.

Comment From: snicoll

As of Spring Framework 6.1, a FactoryBean.OBJECT_TYPE_ATTRIBUTE value that is neither a Class nor a ResolvableType is rejected upfront, see https://github.com/spring-projects/spring-framework/commit/4786e2bf53a3f882c10e25d7ff79a18ff47b5e51.