Announcement Announcement Module
No announcement yet.
System properties and PropertyPlaceholderConfigurer Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • System properties and PropertyPlaceholderConfigurer

    I've been playing around with Spring+Hibernate with an hsqldb database. If you want to run hsqld standalone, you need to specify the URL in the form:


    As this is obviously not something I'd want to 'hard code', I thought I'd try to use a path relative to the home directory, as contained in the system property 'user.dir'. So, in the datasource section of my applicationContext.xml, I tried the following:

    <property name="url">

    Unfortunately, when I tried to use this URL, it showed up without any replacement, i.e., as:


    Is there something else I have to do?

  • #2
    PropertyPlaceholderConfigurer does not support System Properties. You can however "hard code" the path inside a file.


    • #3
      Originally posted by irbouho
      PropertyPlaceholderConfigurer does not support System Properties. You can however "hard code" the path inside a file.
      According to the Javadoc for PropertyPlaceholderConfigurer:

      'A configurer will also check against system properties (e.g. "user.dir") if it cannot resolve a placeholder with any of the specified properties. This can be customized via "systemPropertiesMode".'

      Theer's no explanation of how this customizing is done, but I tried this:

      <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
      <property name="systemPropertiesMode">

      Unfortunately this just gave me the following:

      org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [int] for property 'systemPropertiesMode'; nested exception is java.lang.NumberFormatException: For input string: "SYSTEM_PROPERTIES_MODE_OVERRIDE"

      I may have to fall back to the approach, although I would like to make this really dynamic.


      • #4
        I believe I have solved the problem myself, by the addition of the following to the applicationContext.xml:

        <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer"/>

        I had wrongly believed that there was a default configurer.


        • #5
          Very strange, I had posted a reply in here that PropertyPlaceholderConfigurer does support use of System properties, but it seems to have vanished.

          The System properties can be considered either before or afte the ones coming from the Properties file.


          • #6
            I think it does support the use of system properties. I don't believe that was my problem.