I am in reference to Spring’s @Value annotation as documented here: @Value and Spring profiles.
I need to be able to have different values for a given property such as:
websiteContext=http://localhost:8080/kadjoukor
…according to whether the app is running locally or on the cloud. I am not sure how to achieve that with the @Value("${websiteContext}") annotation…
What is the best practice for dealing with such an issue?
If you are using Spring 3.1 or later, you can take advantage of bean profiles and the CloudFoundry “cloud” profile to load a different properties file depending on the environment. That might look something like this in a Spring XML configuration file:
Here are a few good blog posts that explain how this works in more detail: