Announcement Announcement Module
Collapse
No announcement yet.
bean creation order Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • bean creation order

    Hi there

    I am trying to load a properties file into a PropertyPlaceholderConfigurer using an enviroment var as the locations.

    I then try set one of the properties on a bean

    Code:
    	<beans:bean id="myPropertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
      		<beans:property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_FALLBACK"/>
      		<beans:property name="searchSystemEnvironment" value="true"/>
      		<beans:property name="ignoreResourceNotFound" value="false" />
      		<beans:property name="locations">
    			<beans:list>
    				<beans:value>file:${MY_PROPERTIES_FILE}</beans:value>
    			</beans:list>
    		</beans:property>
    	</beans:bean>
    	
    	 
    	<beans:bean id="test" class="domain.Test">
    		<beans:constructor-arg value="${test.property}" />
    	</beans:bean>
    however, it seems that the bean "test" is being created before the PropertyPlaceholderConfigurer.

    I put a break point in org.springframework.core.io.support.PropertiesLoad erSupport.setLocations()

    if I have the test bean commented out, then my debug stops on this break point. however, if the bean is created on startup, then the error "Could not resolve placeholder 'test.property'", and it never gets to the previous breakpoint

    am I doing something fundamentaly wrong?

    Thanks

  • #2
    use depends-on attribute of <bean

    Comment

    Working...
    X