Linked Questions
27 questions linked to/from how to read System environment variable in Spring applicationContext
52 votes
5 answers
104k views
Java Spring: How to use `@Value` annotation to inject an `Environment` property?
Using a construct such as @Component public class SomeClass { @Inject private Environment env; private String key; @PostConstruct private void init() { key = env....
6 votes
3 answers
14k views
Tomcat + Spring and environment variables
In a Spring file I have: <bean id="propertyConfigurer" class="org.myapp.MyConfigurator"> <property name="locations"> <list> <value>...
7 votes
3 answers
11k views
Getting the present working directory using spring
This is the code to get the present working directory of a java application at runtime. String currentWorkingDirectory = System.getProperty("user.dir")+System.getProperty("file.separator"); Is ...
3 votes
3 answers
26k views
How to Set Environment Varibles for Junit Tests with Spring Framework
I have a class that simply returns environment variables with System.getEnv, and I'm trying to write a JUnit test for it, but I always get just null. I'm trying to use an application-test.yml with all ...
6 votes
1 answer
14k views
Access sqlite db file with jpa
I have a huge sqlite file containing my db. I need to know if it is possible and how to connect to this db as an embedded one with jpa. I'm developing an app that packs this database inside it's own ...
1 vote
2 answers
7k views
propertyPlaceHolderConfigurer and environment variable
I am trying to load a property file from an environment variable, so here's what I tried: <bean id="propertyPlaceholderConfigurer" class="org.springframework.beans.factory.config....
2 votes
1 answer
9k views
NumberFormatException when injecting int property
This is my class : ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("beans.xml"); PropertyPlaceholderConfigurer pph = new PropertyPlaceholderConfigurer(); pph.setLocations(...
2 votes
1 answer
7k views
Read system properties in Spring XML config application with expression language
It seems to be easy, but it does not work. I can't paste system property in my easy example: <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <...
1 vote
2 answers
5k views
Spring to read from my system environment variables
I want to use my system environment variables (i.e use variable FOO that I have defined in my .bash_profile export FOO=BAR) for values in Spring's applicationContext.xml; For example: <bean id="...
1 vote
4 answers
3k views
How to extract the url from application.properties?
I have this application.properties: url.up=${url:http://localhost:8080/upload} And I want to extract the url "http://localhost:8080/upload". How can I extract it? I tried something like ...
2 votes
2 answers
4k views
How to externalize configuration in spring?
I am attempting to externalize the configurations using spring, but cannot get it to work properly.. Here is what I did so far: create a property file inside the war file (src/test/resources/) for ...
1 vote
1 answer
4k views
Using Environment variables in Mybatis properties file
I am using mybatis to connect to database and i have stored some schema information in external properties file. I have kept this property file somewhere on my disk and referring it in my config.xml ...
0 votes
1 answer
2k views
Default and user-supplied property files w/ Spring
I'd like to allow my Spring 3.1.2 application to load configuration properties from a default properties file embedded within my jar and additionally allow the user to specify the path to an ...
0 votes
2 answers
2k views
Load a properties file from a path specified in environment variable in spring
Hello I am new to Spring so please forgive me if its a silly question. I need to load a properties file from a path specified in the environment variables, For example, my environment variable will ...
1 vote
2 answers
802 views
openshift mysql connection NumberFormatException with Tomcat 7 (JBoss EWS 2.0)
I am new to openshift. I created a sample application with spring security and tried to deploy in it. My spring-database.xml fragment looks like below. <bean id="dataSource" class="org....