Spring JavaConfig Reference Guide - Spring Web Services - Parent ...
Spring JavaConfig Reference Guide - Spring Web Services - Parent ... Spring JavaConfig Reference Guide - Spring Web Services - Parent ...
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
- Page 2 and 3: About this document ...............
- Page 4 and 5: About this document1. Document stru
- Page 8 and 9: Overviewconfigurations, the depende
- Page 10 and 11: New & Noteworthy in 1.0.0.m3context
- Page 12 and 13: New & Noteworthy in 1.0.0.m3dataSou
- Page 14 and 15: Quick start3.2. Create bean definit
- Page 16 and 17: Chapter 4. Creating and using bean
- Page 18 and 19: Creating and using bean definitions
- Page 20: Creating and using bean definitions
- Page 23 and 24: Chapter 5. Modularizing configurati
- Page 25: Modularizing configurations5.4. Con
- Page 28 and 29: Using aspects}}...JavaConfigApplica
- Page 30 and 31: Chapter 8. Combining configuration
- Page 32 and 33: Appendix A. RoadmapSee the JavaConf
- Page 34 and 35: Appendix C. Maven2 POM configuratio
- Page 36: Appendix D. Additional resourcesD.1
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