We are going to look at some simple examples, including a full DI-based
implementation of everyone's favorite, "Hello World!" Don't be alarmed if you don't
understand all the code examples right away; full discussions follow later in the
topic.
If you are already familiar with the basics of the Spring Framework, feel free to proceed straight to
Chapter 3 for a discussion of the sample application that you will be building during the course of
this topic. However, even if you are familiar with the basics of Spring, you may find some of the
discussions in this chapter interesting, especially those on packaging and dependencies.
Obtaining the Spring Framework
Before you can get started with any Spring coding, you need to obtain the Spring code. You have a few
options for retrieving the code: you can download a packaged distribution from the Spring web site, or
you can check out the code from the Spring GitHub repository. Another option is to use an application
dependency management tool such as Maven or Ivy, declare the dependency in the configuration file,
and let the tool obtain the required libraries for you.
Downloading a Standard Distribution
Spring hosts its development on the SpringSource download center at www.springsource.org/download.
Visit this page to download the latest release of Spring (version 3.1 at the time of writing). You can also
download milestones/nightly snapshots for upcoming releases or previous versions from the download
center.
Starting with release 3.0, the Spring Framework release comes in two flavors: one with the
documentation included and one without. Prior to version 3.0, Spring used to provide another package
that included all the third-party libraries (e.g., commons-logging, hibernate, etc.). However, Spring now
relies on dependency management tools like Maven and Ivy to express its dependency to third-party
libraries on each of its module. So when you declare your project to depend on any Spring module (e.g.,
spring-context), all the required dependencies will be automatically included. More about this will be
discussed later in this chapter.
Checking Spring Out of GitHub
In case you want to get a grip on new features before they make their way even into the snapshots, you
can check out the source code directly from SpringSource's GitHub repository.
To check out the latest version of the Spring code, first install GitHub, which you can download
from http://git-scm.com/, and then open the Git Bash tool, and run the following command:
git clone git://github.com/SpringSource/spring-framework.git
Understanding Spring Packaging
After you download the package and extract it, under the dist folder, you will find a list of JAR files that
represent each Spring module. After you understand the purpose of each module, you can then select
the modules required in your project and include them in your code. Figure 2-1 shows the dist folder's
content after extracting the downloaded Spring Framework package.
Search WWH :
Custom Search
Previous Page
Spring Framework 3 Topic Index
Next Page
Spring Framework 3 Bookmarks
Home