markthegrea
markthegrea

Reputation: 3861

Injecting property values via Spring by Environment

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?

Upvotes: 1

Views: 1455

Answers (1)

axtavt
axtavt

Reputation: 242786

It should be

@Value ("#{props['frame.server.' + systemProperties['the.environment']]}")

Upvotes: 2

Related Questions