user360321
user360321

Reputation: 177

<context:property-placeholder loading from the filesystem

<context:property-placeholder ignore-unresolvable="true" location="classpath:test.properties" />

Above mentioned way of loading the property files from contex:property-placeholder works just fine. What I want to do is loading the property file from the file system.

Let's say I have the file in C drive C:\spring\test.properties. Here how can I load the file using context:property-placeholder.

Upvotes: 2

Views: 6531

Answers (2)

rushabh
rushabh

Reputation: 31

Give properties to web application(Spring based) from filesystem(External Location)

1) specify placeholder in applications root xml as

2)define enviornment name as "config" in server's context.xml and give path of file

spring.xml

file:#{contextJndi.lookup('java:comp/env/config')}

context.xml

Environment name="config" override="false" type="java.lang.String" value="D:\config.properties"/>

Upvotes: 0

Ian Roberts
Ian Roberts

Reputation: 122364

Use a file: URL instead of a classpath: one

<context:property-placeholder ignore-unresolvable="true"
     location="file:/C:/spring/test.properties" />

Upvotes: 8

Related Questions