properties-file

Why not convert all .properties files to UTF-8?

一曲冷凌霜 提交于 2019-12-07 15:33:25
I work on a java project where labels are externalized and translated into .properties files. Resources in java are read using ISO-8859-1 encoding and thus the .properties files are also stored in ISO-8859-1 encoding. The current files are messed up, sometimes using escapes \u00E4 and sometimes using the actual letter öäü . Also I have russian translations which look like this: code.adr=\u0430\u0434\u0440\u0435\u0441 This could be stored in clear text using UTF-8. Now the question is, why not use UTF-8? Why does Java use ISO-8859-1 instead of UTF-8 per default, backwards compability? Are there

Get the values from the properties file at runtime based on the input - java Spring

不羁岁月 提交于 2019-12-07 05:21:46
问题 I have my colour.roperties file as rose = red lily = white jasmine = pink I need to get the value for colour as String flower = runTimeFlower; @Value("${flower}) String colour; where flower value we will get at runtime. How can I do this in java Spring. I need to get a single value (from among 50 values defined in the properties file )at runtime based on the user input. If i cannot use @Value , Could you tell me other ways to handle this please? 回答1: There is no way to do what you are

How to automatically escape unicode characters in Java property files using Gradle?

两盒软妹~` 提交于 2019-12-07 02:59:16
问题 I'm translating a Java application by using a ResourceBundle with various *.properties files. Now I like to have a Gradle task or want to modify a task to automatically escape any unicode character by replacing it with its ASCII representation, something like Java's native2ascii tool does. This is what I'm done so far with my build file, but the output remains unescaped : import org.apache.tools.ant.filters.EscapeUnicode tasks.withType(ProcessResources) { filesMatching('**/*.properties') {

I am using a combination of @PropertySource and @ConfigurationProperties but I want to overwrite them with an external properties file

别说谁变了你拦得住时间么 提交于 2019-12-06 16:43:44
I have built a spring boot project. Within it, I have a properties class that looks like this: @Configuration @PropertySource(value = "classpath:abc.properties") @ConfigurationProperties public class ABCProperties { private Map<String, String> someUrls; @Bean public Map<String, String> someUrls() { return someUrls; } public Map<String, String> getSomeUrls() { return someUrls; } public void setSomeUrls(Map<String, String> someUrls) { this.someUrls = someUrls; } } The contents of the abc.properties file look like this: someUrls.urlA=someURL someUrls.urlB=someOtherURL Within the project, in the

Error while reading the property file in pom.xml

徘徊边缘 提交于 2019-12-06 12:34:52
问题 I have a sample properties file as following. sample.properties language=English site=www.google.com login=Login I am invoking the property file into my pom.xml using the following plugin and goal as properties-maven-plugin and read-project-properties my pom.xml is <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>properties-maven-plugin</artifactId> <version>1.0.0</version> <executions> <execution> <phase>initialize</phase> <goals> <goal>read-project-properties</goal> </goals>

SPRING MVC - Use an external file as @PropertySource

拥有回忆 提交于 2019-12-06 05:47:48
I was wondering how to use an external file to load some properties for my app in different contexts.. I know I can pass a file in PropertySource annotation. The problem is the path of the file. I mean, it looks like it want a full path to the file, but different environments have different paths for Tomcat directory. My question is: Where is the correct directory to store this files (it must be outside to the app dir otherwise on every deploy it is deleted) and how I can link it in my application. For instance, now i created a /config directory inside the /webapps directory of tomcat. From my

Is a .properties-file suitable for storing hierarchical settings-objects?

元气小坏坏 提交于 2019-12-06 05:03:32
I have been tasked with an assignement at work, that needs persistance of client side settings. These settings are represented by a XML-file in the C# version of the framework I am implementing, and it represents objects with an hierarchical structure of up to six levels. Also, the number of objects in the different levels are sometimes arbitrary, like an ArrayList. Object serialization is unfortunately not an option, due to a requirement of being able to edit the file directly. It has been more than implied that I have to implement the persistance of these settings as a .properties-file, but

Loading properties file in a Java Jersey RESTful web app, to persist throughout the app?

自古美人都是妖i 提交于 2019-12-05 17:50:16
I'm currently building a RESTful API using Jersey. So far, all has been going well, however, all of the configuration entries have been hard coded in. (i.e. Database Host , Database Username , etc...). I'd like to be able to setup a config.properties file that exists in my WEB-INF folder to contain all of these configuration specs. I'm concerned that if I do it the "classic" way of reading the file on the Classpath, I'm performing file I/O for every request. I want to be able to read once on startup (which I know involves a ServletListener in my web.xml file. Here's what I have below: web.xml

How to automatically escape unicode characters in Java property files using Gradle?

安稳与你 提交于 2019-12-05 06:58:59
I'm translating a Java application by using a ResourceBundle with various *.properties files. Now I like to have a Gradle task or want to modify a task to automatically escape any unicode character by replacing it with its ASCII representation, something like Java's native2ascii tool does. This is what I'm done so far with my build file, but the output remains unescaped : import org.apache.tools.ant.filters.EscapeUnicode tasks.withType(ProcessResources) { filesMatching('**/*.properties') { println "\t-> ${it}" filter EscapeUnicode } } Any help is appreciated. You can do it providing the

SpringBoot unknown property in application.properties

时光怂恿深爱的人放手 提交于 2019-12-05 04:55:12
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 Version: 3.8.4.RELEASE as a development environment, but I got this warning in the Editor 'default.to.address' is an unknown property. Should I put this property in another property file ? It's because it's being opened by the STS properties editor which validates properties amongst other things. There's no harm in having it in the application.properties