Announcement Announcement Module
No announcement yet.
PropertyPlaceHolderConfigurration Classpath Problem Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • PropertyPlaceHolderConfigurration Classpath Problem

    I am using PropertyPlaceHolderConfiguration to read the property outside the war file. To do so I used the code
    <bean class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
    <!-- property name="ignoreResourceNotFound" value="true"/> -->

    <!-- property name="location" value="classpath:${config}\" /> -->
    <property name="location" value="file:${config}\" />

    When I give classpath:${config}\ at the startup time it give me error class path resource [C:/Amit/property/] cannot be opened because it does not exist.

    But if I use file: then it works fine.
    I wanted to know what wrong I am doing with classpath:.
    In the examples of PropertyPlaceHolderConfiguration everywhere they are writing value="" , in this case where in classpath it will search I am using web application and using Tomcat or Weblogic, if I user this then where I need to put my file so that it can be read from the classpath.

    Many thanks in advance.

  • #2
    Well obviously ${config} is replaced with "C:\Amit\property" in your configuration. Classpath is the directory where your application's resources are stored (if you use Maven, that's src/main/resources or src/test/resources). So classpath resources should be relative to that directory, not relative to C: disk.


    • #3
      But in my case my property file should be present outside the war directory structure. If I go with src then I need to make change my property file for each environemnt(Dev,QA, Stag,Prod). Hence if I give is there way without src(which is in application classpath) it can read the properties from outside. Like in case of Weblogic there would be conf or user_projects\domains\myDom if I put here, will it read from there.


      • #4
        I know nothing about WebLogic, but it makes no difference. No matter where you deploy/run/test your application, classpath is the directory (or jar file) where your compiled .class files are stored. So resources in the classpath always go together with your application bytecode. If you say "", Spring will search for file in the classpath, wherever it is.

        But do I understand it right that you do not want to keep this file in the classpath for some reason?