Results 1 to 3 of 3

Thread: How to use a system property in applicationContext.xml

  1. #1
    Join Date
    Jan 2006
    Posts
    1

    Default 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. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,632

    Default

    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.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Jun 2005
    Posts
    4,232

    Default

    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.

Posting Permissions

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