Kevin
Kevin

Reputation: 6292

Unable to find property file

I have a number of Java property files which used to be included in the standard resources directory and the following property holder of Spring works fine.

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

For some reason, I need to move them to another location so that they are not included as part of the JAR. The deployment script will handle them and copy them to a specific location called config.

I added the new location to the classpath argument of my java command, however, the above statement always fails, complaining no property file is found. My command is a follows

java -classpath "C:\Deployment\config" ............

And the property file does exist under:

C:\Deployment\config\project\myproperty.properties

Can someone let me know what I did wrong?

Upvotes: 2

Views: 1332

Answers (1)

Paulius Matulionis
Paulius Matulionis

Reputation: 23415

You can try to do it like this:

<context:property-placeholder location="file:${my.config.location}\project\myproperty.properties"/>

And to add the property in the environment properties:

java -Dmy.config.location="C:\Deployment\config" ...

Hope this helps.

Upvotes: 1

Related Questions