How to auto-install a factorybean instance (and not a getObject ()) with annotations?

I know that you can get a reference to a factorybean instance when defining beans with XML ( Spring ). eg:.

<property name="factoryBean" ref="&amp;theFactoryBean" /> 

But can this be done with annotations? (possibly with @Autowired and @Qualifer?)

Do you need to annotate the plant itself so that it can be detected using Spring component scan?

+4
source share
1 answer

Make your bean an implementation of BeanFactoryAware , but as the scaffman says, this is not a good practice.

+1
source

All Articles