diff --git a/spring-framework-reference/src/beans.xml b/spring-framework-reference/src/beans.xml index 4490325b1fa..da2e2b19be8 100644 --- a/spring-framework-reference/src/beans.xml +++ b/spring-framework-reference/src/beans.xml @@ -4392,8 +4392,33 @@ dataSource.url=jdbc:mysql:mydb
Annotation-based container configuration - As mentioned in , using a + + Are annotations better then XML for configuring Spring? + + The introduction of annotation based configurations raised the question of whether + this approach is better or not then XML. The short answer is it depends.. + The long answer is that each approach has it's pros and cons and usually it's up to the developer + to decide which strategy suits her better. + Due to the way they are defined, annotations provide a lot of context in their declaration leading + to shorter, more concise configurations. However XML excels at wiring up components without touching + their source code or recompile them. Some prefer having the wiring close to the source while + others argue that annotated classes are no longer POJOs and further more that the configuration becomes + decentralized and harder to control. + + No matter the choice, Spring can accomodate both styles and even mix them together. It's worth pointing + out that through its JavaConfig option, Spring allows annotations to + be used in a non-invasive way, without touching the target components source code and that + in terms of tooling, all configuration styles are supported by the SpringSource Tool Suite. + + + + + An alternative to XML setups is provided by annotation-based configuration which rely + on the bytecode metadata for wiring up components instead on angle-bracket declarations. + Instead of using XML to describe a bean wiring, the developers moves the configuration into + the component class itself by using annotations on relevant class, method or field declaration. + + As mentioned in , using a BeanPostProcessor in conjunction with annotations is a common means of extending the Spring IoC container. For example, Spring 2.0 introduced the possibility of enforcing required @@ -5307,7 +5332,7 @@ public class JpaMovieFinder implements MovieFinder { by including the annotation-config attribute with a value of false. - +