properties-file

Crashlytics not finding API Key in crashlytics.properties at runtime

那年仲夏 提交于 2019-11-29 03:30:33
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") set("crashlyticsApiSecret", "API_SECRET_1") } release { ... set("crashlyticsApiKey", "API_KEY_2") set("crashlyticsApiSecret", "API_SECRET_2") } } ... productFlavors{...} ... File crashlyticsProperties = new File("${project.projectDir.absolutePath}/crashlytics.properties") applicationVariants.all { variant -> variant.productFlavors.each { flavor -> def variantSuffix = variant.name

Immutable @ConfigurationProperties

南楼画角 提交于 2019-11-29 02:09:04
问题 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 MyProps(String neededProperty) { this.neededProperty = neededProperty; } public String getNeededProperty() { .. } } Approaches I've tried so far: Creating a @Bean of the MyProps class with two constructors Providing two constructors: empty and with

Eclipse wrong Java properties UTF-8 encoding

别等时光非礼了梦想. 提交于 2019-11-29 01:53:10
问题 I have a JavaEE project, in which I use message properties files. The encoding of those file is set to UTF-8. In the file I use the german umlauts like ä , ö , ü . The problem is, sometimes those characters are replaced with unicode like \uFFFD\uFFFD , but not for every character. Now, I have a case where ä and ü are both replaced with \uFFFD\uFFFD , but not for every occurring of ä and ü . The Git diff shows me something like this: mail.adresses=E-Mail hinzufügen: -mail.adresses.multiple=E

How to load java properties file and use in Spark?

心已入冬 提交于 2019-11-28 19:22:55
I want to store the Spark arguments such as input file, output file into a Java property files and pass that file into Spark Driver. I'm using spark-submit for submitting the job but couldn't find a parameter to pass the properties file. Have you got any suggestions? here i found one solution: props file : (mypropsfile.conf) // note: prefix your key with "spark." else props will be ignored. spark.myapp.input /input/path spark.myapp.output /output/path launch $SPARK_HOME/bin/spark-submit --properties-file mypropsfile.conf how to call in code :( inside code) sc.getConf.get("spark.driver.host") /

How can I write Java properties in a defined order?

社会主义新天地 提交于 2019-11-28 06:49:34
I'm using java.util.Properties's store(Writer, String) method to store the properties. In the resulting text file, the properties are stored in a haphazard order. This is what I'm doing: Properties properties = createProperties(); properties.store(new FileWriter(file), null); How can I ensure the properties are written out in alphabetical order, or in the order the properties were added? I'm hoping for a solution simpler than "manually create the properties file". As per "The New Idiot's" suggestion, this stores in alphabetical key order. Properties tmp = new Properties() { @Override public

Spring .properties file: get element as an Array

醉酒当歌 提交于 2019-11-27 18:14:38
I'm loading properties attributes from a .properties file using Spring as follows: file: elements.properties base.module.elementToSearch=1 base.module.elementToSearch=2 base.module.elementToSearch=3 base.module.elementToSearch=4 base.module.elementToSearch=5 base.module.elementToSearch=6 The spring xml file file: myapplication.xml <bean id="some" class="com.some.Class"> <property name="property" value="#{base.module.elementToSearch}" /> </bean> And my Class.java file: Class.java public void setProperty(final List<Integer> elements){ this.elements = elements; } But when debugging, the parameter

Write/Update properties file value in spring

折月煮酒 提交于 2019-11-27 17:50:23
问题 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 any best way to do it. Thanks in advance. 回答1: You can achieve that like this : public void saveParamChanges() { try { // create and set properties into properties object Properties props = new Properties(); props.setProperty("Prop1", "toto");

Spring Property Injection in a final attribute @Value - Java

馋奶兔 提交于 2019-11-27 13:28:44
问题 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 @Value("#{someProps['prop.field']}") String someAttrib ; Then in my spring.xml I would have something like: <util:properties id="someProps" location="classpath:/META-INF/properties/somePropFile.properties" /> This works well, is simple and makes code

Accessing properties file in a JSF application programmatically

旧时模样 提交于 2019-11-27 12:55:08
I am trying to access the i18n properties file I'm using in my JSF application in code. (The idea is to have a page that displays its keys and values as a table actually.) The project is a maven project, and in the src/resources/localization folder, and deployed in the war file in WEB-INF\classes\localization\ java.util.Properties prop = new java.util.Properties(); String path = "localization/stat_codes.properties"; InputStream foo = prop.getClass().getResourceAsStream(path); But the variable foo turns out to be null whatever I set the path variable to, /WEB-INF/classes/localization/stat_codes

Reading properties file from Maven POM file

淺唱寂寞╮ 提交于 2019-11-27 12:21:36
I have Maven POM file with some configuration and in the section plugins, I have maven tomcat plugin with some configuration like this: <configuration> <url>http://localhost:8080/manager/html</url> <server>tomcat</server> </configuration> I'd like to export url setting to some property file for example tomcat.properties with that key: url=http://localhost:8080/manager/html And how can I read this key back in my POM file? Maven allows you to define properties in the project's POM. You can do this using a POM file similar to the following: <project> ... <properties> <server.url>http://localhost