Results 1 to 2 of 2

Thread: bean creation order

Hybrid View

  1. #1

    Default 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. #2
    Join Date
    Dec 2009
    Location
    Pune,India
    Posts
    60

    Default

    use depends-on attribute of <bean

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •