Announcement Announcement Module
Collapse
No announcement yet.
How to use a system property in applicationContext.xml Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to use a system property in applicationContext.xml

    Hi,

    I would like to create an uber-jar of my application that utilises Spring, Hibernate and Lucene, and have the end user specify the path to where the lucene indexes can be stored using a -D command line variable.

    The place I want to put it is here, in my applicationContext.xml: <prop key="hibernate.search.default.indexBase">/chosen/path/to/indexes</prop>

    Any ideas?

    Thanks!


    --
    Dan Hardiker
    Adaptavist.com Ltd

  • #2
    Register a PropertyPlaceHolderConfigurer and put ${} around the property yyou wnat.

    Code:
    <bean class="rg.springframework.beans.factory.config.PropertyPlaceHolderConfigurer"/>
    
    <prop key="hibernate.search.default.indexBase">${luceneIndexes}</prop>
    Now if you start it with -DluceneIndexes=/your/location, the files will be stored in your location.

    You could also let the PropertyPlaceHolderConfigurer read a property file in a specified conf directory and let it read the property from there.

    Comment


    • #3
      Does this work for you?

      Code:
      <prop key="hibernate.search.default.indexBase">${indexBase}</prop>
      Then include a PropertyPlaceholderConfgurer. You can also strategise the system property behaviour with the systemPropertiesMode property of that object.

      Comment

      Working...
      X