Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

CHAPTER 5: Spring Configuration in Detai... > Environment and PropertySource Abstr...

Environment and PropertySource Abstraction

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.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial