properties-file

Using Groovy for variable expansion in Java properties

£可爱£侵袭症+ 提交于 2020-01-03 18:59:13
问题 I frequently use standard Java property files for configuring my Groovy applications. One feature I have been missing is the ability to use variables as part of the property value so they can be expand dynamically during use. I thought I could provide this functionality using the following design: Use a special format to annotate the properties that should be expanded. I have chosen to enclose such templates in double exclamation marks (!!). These property values are essentially a template to

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

爷,独闯天下 提交于 2020-01-02 23:15:12
问题 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

How to load and iterate through properties file in Spring Boot

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-01 19:30:54
问题 I've a properties file in which the values are comma separated. I'm able to get the values as Object as below. Could anyone please tell me how to separate the values and get it in String. .properties key-1 = value1,value11 key-2 = value2,value22 key-3 = value3,value33 key-4 = value4,value44 Code @PropertySource( value = "classpath:test1.properties", name = "test1" ) AbstractEnvironment ae = (AbstractEnvironment)env; org.springframework.core.env.PropertySource test1Source = ae

PropertyPlaceholderConfigurer vs ReloadableResourceBundleMessageSource

不问归期 提交于 2020-01-01 14:25:43
问题 Searching Google on how to configure property file in Spring 3 and I got many different answers. I found that ReloadableResourceBundleMessageSource and PropertyPlaceholderConfigurer can be used for getting properties from property files. Can somebody please explain the difference between these? 回答1: PropertyPlaceholderConfigurer used for properties files to be used in the application context or inside the code with with @value. ResourceBundleMessageSource used for Internationalization &

PropertyPlaceholderConfigurer vs ReloadableResourceBundleMessageSource

六月ゝ 毕业季﹏ 提交于 2020-01-01 14:25:38
问题 Searching Google on how to configure property file in Spring 3 and I got many different answers. I found that ReloadableResourceBundleMessageSource and PropertyPlaceholderConfigurer can be used for getting properties from property files. Can somebody please explain the difference between these? 回答1: PropertyPlaceholderConfigurer used for properties files to be used in the application context or inside the code with with @value. ResourceBundleMessageSource used for Internationalization &

Override Properties file in Spring WebApp at Runtime

試著忘記壹切 提交于 2019-12-29 09:19:08
问题 I am loading properties file in my Spring WebApplication using PropertyPlaceholderConfigurer as below: <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>classpath:db.properties</value> <value>classpath:mail.properties</value> </list> </property> </bean> Now, I want to override some of the properties from mail.properties , so I created an additional entry in my application-context file reading this post, as follows:

Putting properties file into a JTree rather than just displaying it

血红的双手。 提交于 2019-12-25 02:32:56
问题 This is my current code - it just displays the key pair values from my GitCommands.properties file and displays it in my GetAllProperties.java file - is it possible to sort it so it goes in to a JTree rather than just displaying it in a list type format? import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.util.Enumeration; import java.util.Properties; import javax.swing.JTree; import javax.swing.tree.DefaultMutableTreeNode; public class

Proper way to de-escape a string with an escaped colon “:” in python 3.6

 ̄綄美尐妖づ 提交于 2019-12-24 19:37:29
问题 I am attempting to write a python script that converts a .properties file (as read by Ant), and converts the result into a dictionary, mapping keys to values. As part of the process (using configparser.RawConfigParser), I discovered that .properties files have their values escaped, and I decided to follow the top result to try and de-escape them (see How do I un-escape a backslash-escaped string in python?). As I am using python 3 (specifically, python 3.6), I use value = value.encode('utf-8'

Get Maven basedir from a properties file in a SpringBoot project

喜夏-厌秋 提交于 2019-12-24 12:58:25
问题 The Maven project I inherited has some resource files used in JUnits. Those files are referred in a properties file as absolute paths. Let's assume the Maven project is under myproject , where the main pom.xml resides. A config.properties file has: keystore.file=C:/Users/tom/myproject/web/src/test/resources/myfile.jks I want to refer to that resource from a relative path of the Maven project. So I have been trying something like: keystore.file=${project.basedir}/web/src/test/resources/myfile

How can I a get singleton from Guice that's configured with runtime parameters?

倾然丶 夕夏残阳落幕 提交于 2019-12-24 06:49:43
问题 My overall goal is to load properties from a properties file and then inject those properties into my objects. I would also like to use those properties to instantiate certain singleton classes using Guice. My singleton class looks like this: public class MainStore(){ private String hostname; @Inject public void setHostname(@Named("hostname") String hostname){ this.hostname = hostname; } public MainStore(){ System.out.println(hostname); } } I'm trying to instantiate a singleton using this