views:

47

answers:

1

I have a Property File like this:

frame.server.dev=mark.is.cool
frame.server.test=chris.is.cool
frame.server.qa=mitch.is.cool
frame.server.prod=cory.is.cool

I need to inject the correct value based on the environment. Since we have one ear file that we move from environment to environment, I need to do something like this:

<util:properties id="props" location="classpath:ILog-application.properties"/>

and then:

@Value ("props.frame.server.#{systemProperties.the.environment}")
private String server;

However, I cannot get systemProperties to work, nor can I get it to inject anything after a constant. Any help?

+2  A: 

It should be

@Value ("#{props['frame.server.' + systemProperties['the.environment']]}")
axtavt
Perfect. Just what I needed. As you can tell, I am quite a noobie at annotations and properties. I have not found a good tutorial on this that did not assume lots of Spring knowledge.. Thanks!
sliver
@silver: Expression in `#{...}` is a Spring Expression Language, see http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/expressions.html.
axtavt