Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7926973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T19:04:05+00:00 2026-06-03T19:04:05+00:00

We used to have a way to load properties from a file on the

  • 0

We used to have a way to load properties from a file on the classpath:

<context:property-placeholder location="classpath:myConfigFile.properties" />

and it worked great. But now we want to load properties from a specific file on the system that is NOT in the classpath. We wanted to be able to dynamically load the file, so we are using a Java environment variable to populate it. I’ll give a simple example below:

In Java:

  System.setProperty("my.prop.file", "/path/to/myConfigFile.properties");

In Spring XML:

<context:property-placeholder location="${my.prop.file}" />

I’ve also tried it this way, thanks to an idea from Luciano:

<context:property-placeholder properties-ref="prop" />

<util:properties id="prop" location="reso"/>

<bean id="reso" class="org.springframework.core.io.FileSystemResource">
    <constructor-arg index="0" value="${my.prop.file}" />
</bean>

Everything I’ve tried has failed. No matter what I set my.prop.file to. Greatest hits include:

<context:property-placeholder location="/path/to/myConfigFile.properties" />
(ClassNotFoundException: .path.to.myConfigFile.properties)

<context:property-placeholder location="file:/path/to/myConfigFile.properties" />
(ClassNotFoundException: file:.path.to.myConfigFile.properties)

<context:property-placeholder location="file:///path/to/myConfigFile.properties" />
(ClassNotFoundException: file:...path.to.myConfigFile.properties)

How do you use property-placeholders with a location that is on the file system and NOT on the classpath? We are using Spring 3.0.5.

It turns out there was a problem with the script running the Java program that loads the spring file. Thank you for helping. I am going to request that this question be deleted, as the original code works after all.
Thank you for your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T19:04:06+00:00Added an answer on June 3, 2026 at 7:04 pm

    What about this way?

    <context:property-placeholder properties-ref="prop" />
    
    <util:properties id="prop" location="reso"/>
    
    <bean id="reso" class="org.springframework.core.io.FileSystemResource">
        <constructor-arg index="0" value="/yourpathandfile" />
    </bean>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have used the following code to create a file in a temp location
I have not found a way to load an RSA private key from a
I recently switched to command-line git for my personal projects. I have used 3-way
Since now I have only used plugin for editing and the way I use
We have used Shibboleth to authenticate users. It works great. The issue is that
Currently i have an application that reads and writes several properties from one or
I have a class with multiple public properties whose objects are being used in
I have used this tutorial from Google to build a web app that finds
Is there a way to load files stored inside JARs using getResourceAsStream from Tomcat
Good day all, i have a load of images i want to display from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.