Announcement Announcement Module
Collapse
No announcement yet.
how to override a property of a bean? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to override a property of a bean?

    hello,
    i have a standard sessionfactory bean (i removed irrelevant stuff):

    Code:
      
    <bean id="sessionFactory"
          class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
    	<property name="dataSource">
    	    <ref bean="dataSource" />
    	</property>
    	<property name="hibernateProperties">
    		<props>
    	        ...
                    </props>
    	</property>
    </bean>
    Now, when I launch my unit tests, i'd like to add a property to the hibernateProperties property definition. In particular, i'd like to extend it with the following:

    Code:
    <property name="hibernateProperties">
        <props>
    	...
    	<prop key="hibernate.lucene.default.directory_provider">
    	    org.hibernate.lucene.store.RAMDirectoryProvider
    	</prop>
         </props>
    </property>
    what is the best practice to solve this problem?
    thanks,
    valerio
    Last edited by ervalerio; Sep 21st, 2006, 11:17 AM. Reason: code indent

  • #2
    check out PropertyOverrideConfigurer/PropertyPlaceholderConfigurer

    When you are running unit tests, just put appropriate property file in the classpath and/or load an additional context xml file into the context root when you are running your unit test.

    Comment


    • #3
      does the additional context xml file has to provide a complete definition of the bean, or i can simply put some 'property' element into an xml file and load it as a spring context?

      Comment

      Working...
      X