Questions tagged [properties-file]

A .properties file is either a simple text file or an XML file containing pairs of keys and values. Java and related technologies frequently use .properties files to store configuration information.

Properties files can also be used to store Strings for Internationalization and Localization and error messages.

and related technologies frequently use properties files.

Further Reading:

1316 questions
544
votes
31 answers

How to access a value defined in the application.properties file in Spring Boot

I want to access values provided in application.properties, e.g.: logging.level.org.springframework.web: DEBUG logging.level.org.hibernate: ERROR logging.file=${HOME}/application.log userBucket.path=${HOME}/bucket I want to access userBucket.path…
Qasim
  • 9,058
  • 8
  • 36
  • 50
230
votes
6 answers

Where to place and how to read configuration resource files in servlet based application?

In my web application I have to send email to set of predefined users like finance@xyz.example, so I wish to add that to a .properties file and access it when required. Is this a correct procedure, if so then where should I place this file? I am…
sansknwoledge
  • 4,209
  • 9
  • 38
  • 61
147
votes
11 answers

How to read values from properties file?

I am using spring. I need to read values from properties file. This is internal properties file not the external properties file. Properties file can be as below. some.properties ---file name. values are below. abc = abc def = dsd ghi = weds jil…
user1016403
  • 12,151
  • 35
  • 108
  • 137
138
votes
3 answers

How to read an external properties file in Maven

Does anyone know how to read a x.properties file in Maven. I know there are ways to use resource filtering to read a properties file and set values from that, but I want a way in my pom.xml like:
Dougnukem
  • 14,709
  • 24
  • 89
  • 130
138
votes
10 answers

How do I read properties defined in local.properties in build.gradle

I have set sdk.dir and ndk.dir in local.properties. How do I read the values of sdk.dir and ndk.dir in the build.gradle file?
Vikram
  • 11,885
  • 5
  • 22
  • 16
116
votes
9 answers

Loading a properties file from Java package

I need to read a properties files that's buried in my package structure in com.al.common.email.templates. I've tried everything and I can't figure it out. In the end, my code will be running in a servlet container, but I don't want to depend on the…
SacramentoJoe
  • 1,219
  • 2
  • 10
  • 10
115
votes
5 answers

Spring .properties file: get element as an Array

I'm loading properties attributes from a .properties file using Spring as follows: file:…
RamonBoza
  • 8,898
  • 6
  • 36
  • 48
70
votes
8 answers

How to fill HashMap from java property file with Spring @Value

Is it possible to use Spring @Value, to map values from properties file to the HashMap. Currently I have something like this, and mapping one value is not a problem. But I need to map custom values in HashMap expirations. Is something like this…
d-sauer
  • 1,485
  • 1
  • 15
  • 20
64
votes
10 answers

How to store an array in a Java properties file

I'm currently making a .properties file that needs to be loaded and transformed into an array. There is a possibility of anywhere from 0-25 of each of the property keys to exist. I tried a few implementations but I'm just stuck at doing this…
yep
  • 1,263
  • 1
  • 9
  • 13
63
votes
9 answers

Immutable @ConfigurationProperties

Is it possible to have immutable (final) fields with Spring Boot's @ConfigurationProperties annotation? Example below @ConfigurationProperties(prefix = "example") public final class MyProps { private final String neededProperty; public…
RJo
  • 15,631
  • 5
  • 32
  • 63
55
votes
2 answers

Spring Property Injection in a final attribute @Value - Java

A simple question on Spring injection from a properties file for a final attribute. I have a properties file which I want to store a file path in. Generally when I use properties files I setup class attributes using something like this: private…
NightWolf
  • 7,694
  • 9
  • 74
  • 121
55
votes
3 answers

Does spring boot support using both properties and yml files at the same time?

I have a spring boot application and I want to use both a yml file for my application properties and also a plain application-${profile}.properties file set to configure my application. So my question is can this be done and if so, how do you…
Scott C.
  • 3,672
  • 4
  • 18
  • 20
55
votes
3 answers

How to share common properties among several maven projects?

I have several projects built by maven, and I want to share some common properties among them - spring version, mysql driver version, svn base url, etc. - so I can update them once and it will be reflected on all projects. I thought of having a…
David Rabinowitz
  • 29,904
  • 14
  • 93
  • 125
54
votes
8 answers

Get values from properties file using Groovy

How to get values from properties file using Groovy? I require to have a property file (.properties) which would have file names as key, and their destination path as the value. I will need the key to be resolved at runtime, depending on file that…
user3151610
  • 637
  • 1
  • 5
  • 12
50
votes
2 answers

How do I use, or set up sonar-project.properties file?

I have very little exposure to SonarQube but have been asked to make a document explaining how to set up / use "sonar-project.properties file". Any information or input would be greatly appreciated.
Charles.savin
  • 511
  • 1
  • 4
  • 4
1
2 3
87 88