Spring JavaConfig Reference Guide - Spring Web Services - Parent ...

Spring JavaConfig Reference Guide - Spring Web Services - Parent ... Spring JavaConfig Reference Guide - Spring Web Services - Parent ...

static.springsource.org
from static.springsource.org More from this publisher
13.07.2015 Views

Part I. IntroductionIn Part I we explain what JavaConfig is, how it fits into the larger Spring configuration landscape, and make thecase as to why it is a compelling option. After reading this part you'll be ready to create a basic configurationand evaluate JavaConfig for yourself. Finally, you'll be ready to move on to Part II and explore the JavaConfigAPI in detail.Chapter 1, OverviewChapter 2, New & Noteworthy in 1.0.0.m3Chapter 3, Quick startSpring JavaConfig 1

Chapter 1. Overview1.1. What is JavaConfig?Spring JavaConfig is a product of the Spring community that provides a pure-Java approach to configuring theSpring IoC Container. While JavaConfig aims to be a feature-complete option for configuration, it can be (andoften is) used in conjunction with the more well-known XML-based configuration approach.See Section 8.1, “JavaConfig and XML” for more information on using JavaConfig and XML together1.2. Why JavaConfig?The Spring IoC Container is the leading dependency injection framework. It provides sophisticated dependencyinjection capabilities as well as advanced features for aspect-oriented programming. Today the majority ofSpring users configure the Spring container using XML. This works very well, and in many cases is ideal.However, some developers find configuring the Spring container via Java a more natural or appropriateapproach, for a variety of reasons.Motivations of JavaConfig include:Object-oriented configuration. Because configurations are defined as classes in JavaConfig, users can takefull advantage of object-oriented features in Java. One configuration class may subclass another, overriding its@Bean methods, etc.Reduced or eliminated XML configuration. The benefits of externalized configuration based on theprinciples of dependency injection have been proven. However, many developers would prefer not to switchback and forth between XML and Java. JavaConfig provides developers with a pure-Java approach toconfiguring the Spring container that is conceptually similar to XML configuration. It is technically possible toconfigure the container using only JavaConfig configuration classes, however in practice many have found itideal to mix-and-match JavaConfig with XML. See Section 8.1, “JavaConfig and XML” for details.Type-safe and refactoring-friendly. JavaConfig provides a type-safe approach to configuring the Springcontainer. Thanks to Java 5.0's support for generics, it is now possible to retrieve beans by type rather than byname, free of any casting or string-based lookups. See Section 4.3.2.1, “Type-safe access” for details.1.3. Requirements1.3.1. Runtime EnvironmentJavaConfig takes full advantage of Java 5.0 language features, especially annotations and generics. A Java 5.0+runtime environment is a requirement for using JavaConfig.. For an introduction to annotations and other Java5.0 features, see http://java.sun.com/docs/books/tutorial/java/javaOO/annotations.html andhttp://java.sun.com/j2se/1.5.0/docs/relnotes/features.html#lang1.3.2. Project DependenciesEvery effort has been made to reduce the number of dependencies Spring JavaConfig requires. For very simpleSpring JavaConfig 2

Part I. IntroductionIn Part I we explain what <strong>JavaConfig</strong> is, how it fits into the larger <strong>Spring</strong> configuration landscape, and make thecase as to why it is a compelling option. After reading this part you'll be ready to create a basic configurationand evaluate <strong>JavaConfig</strong> for yourself. Finally, you'll be ready to move on to Part II and explore the <strong>JavaConfig</strong>API in detail.Chapter 1, OverviewChapter 2, New & Noteworthy in 1.0.0.m3Chapter 3, Quick start<strong>Spring</strong> <strong>JavaConfig</strong> 1

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!