properties-file

How to use YamlPropertiesFactoryBean to load YAML files using Spring Framework 4.1?

。_饼干妹妹 提交于 2019-11-26 04:48:08
问题 I have a spring application that is currently using *.properties files and I want to have it using YAML files instead. I found the class YamlPropertiesFactoryBean that seems to be capable of doing what I need. My problem is that I\'m not sure how to use this class in my Spring application (which is using annotation based configuration). It seems I should configure it in the PropertySourcesPlaceholderConfigurer with the setBeanFactory method. Previously I was loading property files using

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

无人久伴 提交于 2019-11-26 04:47:30
问题 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 possible? @Service @PropertySource(value = \"classpath:my_service.properties\") public class SomeServiceImpl implements SomeService { @Value(\"#{conf[\'service.cache\']}\") private final boolean useCache = false; @Value(\"#{conf[\'service.expiration.[

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

前提是你 提交于 2019-11-26 04:33:07
问题 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 in my main program in a Spring Boot application. 回答1: You can use the @Value annotation and access the property in whichever Spring bean you're using @Value("${userBucket.path}") private String userBucketPath; The Externalized Configuration section

How to read values from properties file?

只愿长相守 提交于 2019-11-26 02:57:40
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 = sdd I need to read those values from the properties file not in traditional way. How to achieve it? Is there any latest approach with spring 3.0? Configure PropertyPlaceholder in your context: <context:property-placeholder location="classpath*:my.properties"/> Then you refer to the properties in your beans: @Component class MyClass { @Value("${my

How to read values from properties file?

邮差的信 提交于 2019-11-26 01:56:27
问题 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 = sdd I need to read those values from the properties file not in traditional way. How to achieve it? Is there any latest approach with spring 3.0? 回答1: Configure PropertyPlaceholder in your context: <context:property-placeholder location="classpath*

How to read an external properties file in Maven

笑着哭i 提交于 2019-11-26 01:47:17
问题 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: <properties file=\"x.properties\"> </properties> There was some discussion about this: Maven External Properties 回答1: Try the Maven Properties Plugin 回答2: Using the suggested Maven properties plugin I was able to read in a buildNumber.properties file that I use to version my builds. <build> <plugins>

Loading a properties file from Java package

穿精又带淫゛_ 提交于 2019-11-26 01:46:47
问题 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 container for anything. I write JUnit test cases and it needs to work in both. 回答1: When loading the Properties from a Class in the package com.al.common.email.templates you can use Properties prop = new Properties(); InputStream in = getClass

How to read an external properties file in Maven

流过昼夜 提交于 2019-11-26 01:04:48
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: <properties file="x.properties"> </properties> There was some discussion about this: Maven External Properties Try the Maven Properties Plugin Dougnukem Using the suggested Maven properties plugin I was able to read in a buildNumber.properties file that I use to version my builds. <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>properties-maven-plugin</artifactId> <version

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

痴心易碎 提交于 2019-11-25 21:37:16
问题 In my web application I have to send email to set of predefined users like finance@xyz.com , 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 using Netbeans IDE which is having two separate folders for source and JSP files. 回答1: It's your choice. There are basically three ways in a Java web application archive (WAR): 1. Put it in classpath So that you can load it by ClassLoader

Loading a properties file from Java package

a 夏天 提交于 2019-11-25 20:49:26
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 container for anything. I write JUnit test cases and it needs to work in both. Joachim Sauer When loading the Properties from a Class in the package com.al.common.email.templates you can use Properties prop = new Properties(); InputStream in = getClass().getResourceAsStream("foo.properties"); prop.load(in); in.close(); (Add all the necessary