Announcement Announcement Module
Collapse
No announcement yet.
refrencing a properties file Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • refrencing a properties file

    hi
    in my applicationContext.xml i have code like this

    Code:
    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <value>classpath:config/jdbc.properties</value>
        </property>
    </bean>
    
    <bean id="dataSource" destroy-method="close"
          class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="${jdbc.driverClassName}"/>
        <property name="url" value="${jdbc.url}"/>
        <property name="username" value="${jdbc.username}"/>
        <property name="password" value="${jdbc.password}"/>
    </bean>
    Instead of keeping under config i want to keep this properties file under root. and read from there.
    As part of my porject i have to supply a executable jar file where user can change this properties file.
    i tried changing classpath:jdbc.prperties keeping this jdbc.properties under top level,but didn't work, it only works if i keep this file under config.
    how can i do this. somebody please response ASAP.
    thanks
    AD

  • #2
    Try prefixing it with a / that might work. You can ofcourse also specify a file: prefix and encode a hard path (we do it with some property files which are placed in the tomcat/conf directory).

    Comment


    • #3
      i tried with all things like adding / and ../ , ./ etc., for everything it gives filenotfoundexception.

      if i keep this file under config and change classpath:config/jdbc.properties it works ok. but i want to keep out side conf dir and work

      Comment


      • #4
        Originally posted by mdeinum View Post
        Try prefixing it with a / that might work. You can ofcourse also specify a file: prefix and encode a hard path (we do it with some property files which are placed in the tomcat/conf directory).
        Thanks mdeinum

        i tried finally with file: that works ok.

        Comment


        • #5
          If using JBoss, a good option is to use the properties service and bind the property to the JNDI context. I believe it get more manageable.

          Daniel

          Comment

          Working...
          X