Setting Active Profile And Property Sources In Spring MVC - Bartosz Kielczewski
Often there are times when we need to access settings stored in property files depending on the environment we are in. For example database settings are likely to be different in development, testing and production environments. For this reason Spring offers a concept profile that appeared since version 3.1. That allows to selectively enable @Configuration
classes for active profile thanks to @Profile
annotation.
Setting the active profile is an environment property of ApplicationContext
. While for command-line apps this is easy thing to do, for web applications that could be little dirty, unless they take advantage of WebApplicationInitializer and Servlet 3 API to programmaticaly configure their ApplicationContext
rather than in traditional way with web.xml
. I'm about to show you how that can be implemented.
Read full article from Setting Active Profile And Property Sources In Spring MVC - Bartosz Kielczewski
No comments:
Post a Comment