Jeronimo Spuri Murguia opened SPR-15630 and commented

When using a property placeholder to select a factory bean the property placeholder is not resolved.

This configuration:

1. app.properties
factory=helloFactory
<context:property-placeholder location="classpath:app.properties"/>
<bean id="helloFactory" class="HelloFactory" />
<bean id="hello" factory-bean="${factory}" factory-method="buildHello"/>

Results in:

WARNING: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named '${factory}' available
Exception in thread "main" org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named '${factory}' available

Affects: 4.3.8

Reference URL: https://github.com/jspurim/spring-framework-issues/tree/master/SPR-15630

1 votes, 2 watchers

Comment From: jhoeller

I cannot reproduce this. Having added a unit test for it, this works fine, as expected from the factoryBeanName treatment in the BeanDefinitionVisitor class. If this does not get resolved in a particular setup, it is worth double-checking that placeholder setup.