1

Where should I keep my .properties file in java project so that it should be outside war file. And what are the steps should I follow to implement

  • Possible duplicate of (https://stackoverflow.com/questions/2161054/where-to-place-and-how-to-read-configuration-resource-files-in-servlet-based-app) – Nawnit Sen Sep 27 '18 at 01:37

1 Answers1

0

In addition to the Nawnit Sen's comment.

As for me I've put it in local disk file system.

Also I've granted my tomcat user all privileges to the folder.

In the root-context.xml file I've registered two properties files for both cases(I develop on a Windows and deploy on a Linux). You could register only one properties file

<context:property-placeholder location="file:/path/to/application.properties" order="1" ignore-resource-not-found="true" ignore-unresolvable="true" />
<context:property-placeholder location="file:C:/path/to/application.properties" order="2" ignore-resource-not-found="true" ignore-unresolvable="true" />

Now in your class you could get the property like this

import org.springframework.beans.factory.annotation.Value;

@Value("${someProperty}")  
private String yourProperty;
John
  • 446
  • 6
  • 16