For your convenience Apress has placed some of the front
matter material after the index. Please use the Bookmarks
and Contents at a Glance links to access them.
v
Contents at a Glance
Contents..................................................................................................................vii
About the Authors................................................................................................ xxix
About the Technical Reviewer .............................................................................. xxx
■ Chapter 1: Introducing Spring..............................................................................1
■ Chapter 2: Getting Started .................................................................................13
■ Chapter 3: The Sample Application....................................................................37
■ Chapter 4: Introducing IoC and DI in Spring ......................................................53
■ Chapter 5: Spring Configuration in Detail ........................................................113
■ Chapter 6: Introducing Spring AOP ..................................................................181
■ Chapter 7: More Spring AOP and Annotations .................................................229
■ Chapter 8: Spring JDBC Support ......................................................................269
■ Chapter 9: Using Hibernate in Spring...............................................................317
■ Chapter 10: Data Access in Spring with JPA2 .................................................345
■ Chapter 11: Using MyBatis in Spring ...............................................................397
■ Chapter 12: Designing and Implementing Spring-Based Applications ............437
■ Chapter 13: Transaction Management.............................................................459
■ Chapter 14: Validation with Type Conversion and Formatting.........................495
■ Chapter 15: Task Scheduling in Spring............................................................523
■ Chapter 16: Using Spring Remoting.................................................................539
vi
■ Chapter 17: Web Applications with Spring ......................................................585
■ Chapter 18: Spring Web Flow and JSF.............................................................663
■ Chapter 19: Spring Testing ..............................................................................707
■ Chapter 20: Spring Projects: Batch, Integration, and Roo ...............................737
■ Chapter 21: Sample Application in Detail ........................................................775
■ Chapter 22: Scripting Support in Spring..........................................................819
■ Chapter 23: Spring Application Monitoring .....................................................839
■ Appendix A: SpringSource Tool Suite ..............................................................869
Index.....................................................................................................................897
C H A P T E R 1
1
Introducing Spring
When we think of the community of Java developers, we are reminded of the hordes of gold rush
prospectors of the late 1840s, frantically panning the rivers of North America looking for fragments of
gold. As Java developers, our rivers run rife with open source projects, but, like the prospectors, finding a
useful project can be time-consuming and arduous.
A common gripe with many open source Java projects is that they are conceived merely out of the
need to fill the gap in the implementation of the latest buzzword-heavy technology or pattern. Having
said that, many high-quality, usable projects meet and address a real need for real applications, and
during the course of this book, you will meet a subset of these projects. You will get to know one in
particular rather well—Spring.
Throughout this book, you will see many applications of different open source technologies, all of
which are unified under the Spring Framework. When working with Spring, an application developer
can use a large variety of open source tools, without needing to write reams of code and without
coupling his application too closely to any particular tool.
In this chapter, as its title implies, we introduce you to the Spring Framework, rather than looking at
any solid examples or explanations. If you are already familiar with the Spring project, then you might
want to skip this chapter and proceed straight to Chapter 2.
What Is Spring?
Perhaps one the hardest parts of actually explaining Spring as a technology is classifying exactly what it
is. Typically, Spring is described as a lightweight framework for building Java applications, but that
statement brings up two interesting points. First, you can use Spring to build any application in Java
(e.g., stand-alone, Web, JEE applications, etc.), unlike many other frameworks such as Apache Struts,
which is limited to web applications. Second, the lightweight part of the description doesn’t really refer
to the number of classes or the size of the distribution, but rather, it defines the principle of the Spring
philosophy as a whole—that is, minimal impact. Spring is lightweight in the sense that you have to make
few, if any, changes to your application code to gain the benefits of the Spring core, and should you
choose to discontinue using Spring at any point, you will find doing so quite simple. Notice that we
qualified that last statement to refer to the Spring core only—many of the extra Spring components,
such as data access, require a much closer coupling to the Spring Framework. However, the benefits of
this coupling are quite clear, and throughout the book we present techniques for minimizing the impact
this has on your application.
- 1
- 2
- 3
- 4
前往页