Let's first try to isolate it to a database vs Spring issue. Can see whether ${userName} is injected properly in XML? One way to do that is to create a "DenisTest" object and inject it there.
I found the problem. My config doesn't inject property when it names 'username'.
I changed name of property to 'pgUsername' and now it works perfectly.
And now I have another question: can somebody explain me why property with name 'username' don't work in my situation?
(sorry for bad English)
Denis Viktorov
Greenhorn
Joined: Oct 29, 2012
Posts: 3
posted
0
Okay, i understand the problem.
Spring 3.1 by default loads not only my properties, but also environment vars/props.
In my situations Spring loads windows environment variables and among them was 'username' variable, which overrides my 'username' property.
Denis Viktorov wrote:Okay, i understand the problem.
Spring 3.1 by default loads not only my properties, but also environment vars/props.
In my situations Spring loads windows environment variables and among them was 'username' variable, which overrides my 'username' property.
Yeah that is a funny gotcha that sometimes happens. The properties loader for context, was PropertyPlaceholderConfig. It will by default first look in the .properties file, then go to System.getProperty(), then look at OS environment variables, and use the first one it finds. That is by default. You can change that, you can flip the order, or you can tell it to just use the .properties file and look no further. Those are properties of the class that you can set in your configuration.