Developing enterprise application using Spring Framework is much simpler than using standard Java EE in many ways. Even though Java EE’s declarative programming model using EJB simplifies infrastructural aspects of development such as transactions and security, t still introduces unwanted complexity to the application as a whole. Developers need to still write more Framework code than the application code. Over the period Java EE has also redefined itself to introduce new programming techniques like Aspect Oriented Programming (AOP) and Dependency Injection (DI). So many new Frameworks got evolved using these techniques. Leading from this pack of Framework at the moment is by Spring Framework by a long way. In this chapter I will try to give you details on various aspects of Spring Framework, along with the sample application that will be used throughout this book to show the various concepts in this Framework.
In this chapter, I will give you details on how you can start building applications with Spring Framework. I will also give details on the sample application on which the entire book is based. It also talks about the some basic concepts which are very much essential for understanding Spring in a holistic way.
Developing with Spring Framework
Getting the Spring Framework
Before you get started, you need to get the Spring Framework. You have two options to do so: you can either download the package distribution from Spring website, or you can checkout the source from github.
Downloading standard package distribution
Visit http://www.springsource.org/download/community?project=Spring%2520Framework and download the latest Spring release (version 3.1.1.RELEASE at the time of writing). Previous releases can also be found in this same page.
Checking out source from github
Alternatively you can visit https://github.com/SpringSource/spring-Framework and can download as required or fork the Framework and create your own repository and play around with it.
Using Maven Build Framework
If you are using Maven Build Framework for building your application, you can download the necessary artifacts into your project by mere declaring the maven repository in your build xml called as pom.xml. You will have to make sure that your machine is appropriately configured so that your Maven can look into the repository URL and download the necessary artifacts which you require in your project. Declare the repository as follows in your pom.xml:
Listing 1-1. Repository declaration in pom.xml if you are using maven as your build tool
After that declare the spring modules that you require in your project as below (in the below example spring-context jar with version 3.1.1.RELEASE will be downloaded into the project and set dependency on):
The Spring Framework is a series of JAR files, which we can get by two ways as explained in the above section. To install it all you really have to do is extract the downloaded compressed file to some location on your computer, and then reference the appropriate JARs in a Java project.
Spring Dependencies Structure
Quite simply the dependency between various jars comprising the Spring Framework can be summarized as below:
Figure 1 Spring Framework Dependencies
Page Visitors: 6679