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
22
votes
5 answers

Spring-Boot multi module project load property-file

I have a Spring-Boot-Application as a multimodule-Project in maven. The structure is as follows: Parent-Project |--MainApplication |--Module1 |--ModuleN In the MainApplication project there is the main() method class annotated with…
Daniel
  • 1,027
  • 1
  • 8
  • 23
21
votes
5 answers

SpringBoot unknown property in application.properties

I've generated a Spring Boot web application using Spring Initializr, using embedded Tomcat + Thymeleaf template engine. I put this property in my application.properties default.to.address=nunito.calzada@gmail.com I am using Spring Tool Suite…
Nuñito Calzada
  • 4,394
  • 47
  • 174
  • 301
21
votes
2 answers

boolean values in Spring application.properties file?

Is it possible to have boolean values in Spring configuration file? I wrote the following field in my bean: @Value("${pdk.populatedemo}") private boolean populateDemo; but if causes the following exception: Could not autowire field: private boolean…
Dims
  • 47,675
  • 117
  • 331
  • 600
19
votes
3 answers

Difference between "get' VS "getProperty"

Properties myProp = new Properties(); myProp.put("material", "steel"); Properties prop1 = new Properties(myProp); System.out.println(prop1.get("material") + ", " + prop1.getProperty("material")); // outputs "null, steel" Isn't get similar to…
bouncingHippo
  • 5,940
  • 21
  • 67
  • 107
18
votes
3 answers

Dynamic @Value-equivalent in Spring?

I have a Spring-managed bean that loads properties using a property-placeholder in its associated context.xml: I can access properties using Spring's @Value annotations at…
Doches
  • 3,276
  • 2
  • 19
  • 26
17
votes
6 answers

How to read a properties file in javascript from project directory?

I'm building a Chrome Packaged App. I want to put the script configuration if a config file in a resource directory and on startup want to read that by Javascript. For example Project…
D.S
  • 1,110
  • 3
  • 11
  • 26
16
votes
2 answers

Write/Update properties file value in spring

I have some requirement where I want to write/update the value in the properties file I am using the my spring application. I have googled it but I have not found a direct way of doing it using Spring. Does any one aware of how to do it or is there…
mevada.yogesh
  • 1,118
  • 3
  • 12
  • 35
16
votes
2 answers

Crashlytics not finding API Key in crashlytics.properties at runtime

I'm currently implementing the API Key switching script suggested here, except with build types instead of flavors. My build.gradle looks like this: ... buildTypes { debug { ... set("crashlyticsApiKey", "API_KEY_1") …
15
votes
5 answers

Correctly using Spring environment profiles in order to manage PropertySourcesPlaceholderConfigurer and sets of properties files

I am working on a Spring application and I am realizing that I have an issue with the way I manage my properties. I use Spring environment profiles in order to load my properties and I've recently added more profiles which has made my properties…
balteo
  • 23,602
  • 63
  • 219
  • 412
15
votes
3 answers

PropertyPlaceholderConfigurer and environment variables in .properties files

I have a Spring application-context.xml with PropertyPlaceholderConfigurer to get properties' values from .properties file. Main and test source folders have separate .properties file. The issue is that I need to use environment variables in…
14
votes
2 answers

Spring boot yml ResourceBundle file

I'm using MessageSource of Spring to load errors messages from a .properties file in classpath. My properties respect a certain "template" such as {Object}.{field}.{unrespectedConstraint} Example : userRegistrationDto.password.Size= Le mot de passe…
Radouane ROUFID
  • 10,595
  • 9
  • 42
  • 80
14
votes
2 answers

Viewing current Spring (Boot) properties

I run a Spring Boot application as a .jar file which partly takes its properties from application.yml residing inside the jar while the other part of properties is being provided from another application.yml residing outside the jar. Some of the…
Ewgenij Sokolovski
  • 897
  • 1
  • 12
  • 31
14
votes
2 answers

How to use single quotes with MessageFormat

On my current project, we are using properties files for strings. Those strings are then "formatted" using MessageFormat. Unfortunately, MessagFormat has a handling of single quotes that becomes a bit of a hindrance in languages, such as French,…
AbVog
  • 1,435
  • 22
  • 35
14
votes
6 answers

@PropertySource in a Jar for an external file on the classpath

I'm trying to use the Spring framework's @PropertySource annotation in a Jar to load a properties file from outside the jar, but it's not finding the file. I need the properties file to be external to the Jar so it can be edited. I don't know the…
brianmearns
  • 9,581
  • 10
  • 52
  • 79
12
votes
2 answers

Constants and properties in java

Java best practices recommends read properties as constants. So, what do you think is the best approach to reach it? My approach is: A Configuration class to read the properties file only one time (singleton pattern) and use this class to read…
Esteban S
  • 1,859
  • 5
  • 22
  • 43
1 2
3
87 88