February 2015
Intermediate to advanced
178 pages
3h 47m
English
Spring 3.1 introduced a feature called profiles. Profiles allow you to build one package that can be deployed in all environments, such as dev, test, prod, perf, and so on.
If we define a system property, spring.profiles.active, or annotate a test class with @ActiveProfiles and set the active profile names, Spring loads the beans from the context where the profile name matches or no profile name is defined. We can create different beans depending on the profile name using an XML configuration or the @Profile annotation.
Suppose you have a dev environment and a prod environment; you use a JNDI lookup for DataSource in prod, but in dev, you build DataSource, as in the following snippet:
<jee:jndi-lookup id="common-Datasource" ...Read now
Unlock full access