Announcement Announcement Module
Collapse
No announcement yet.
How to use relative location path in property-placeholder Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to use relative location path in property-placeholder

    Hello,

    I tried to use property placeholder to externalize some of the database configuration.

    I have an executable uber jar that is created through Maven shaded plugin. I want to put the properties file in the same directory as the jar file and have Spring to load it. Below is what my directory looks like.

    /dir
    myapp.jar
    config.properties

    According to documentation, I should be able to use the following in the applicationcontext.xml.

    <context: property-placeholder location="file:config.properties" />

    However during loading, I am getting the following error:

    org.springframework.beans.factory.BeanInitializati onException: Could not load properties; nested exception is java.io.FileNotFoundException: config.properties (No such file or directory).

    What could have been wrong?

    Thanks,
    Suriyanto

  • #2
    Hi! is it a Web Application?, in that case I think you should write

    location="file:/dir/config.properties"

    BTW, if the file it is your classpath, you can use the classpath prefix.

    location="classpath:/path/to/the/file/in/the/classpath/config.properties"

    In this case

    location="classpath:/dir/config.properties"

    If none of these work out, let me know.

    Regards!

    Comment

    Working...
    X