Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
From the previous section, you already saw the usage of Spring’s profile feature. To set the active profile, we need to access the Environment interface. The Environment interface is a new abstraction layer introduced in Spring 3.1; it serves to encapsulate the environment of the running Spring application.
Besides the profile, other key pieces of information encapsulated by the Environment interface are properties. Properties are used to store the application’s underlying environment configuration, such as the location of the application folder, database connection information, and so on.
The Environment and PropertySource abstraction features in Spring 3.1 assist us as developers in accessing various configuration information from the running platform. Under the abstraction, all system properties, environment variables, and application properties are served by the Environment interface, which Spring populates when bootstrapping the ApplicationContext. Listing 5-59 shows a simple example.