From 1119c8fde38e28ced2083496a3cf57be393fdd30 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Mon, 28 May 2018 17:52:49 +0200 Subject: [PATCH] Update @ContextConfiguration example --- Spring-Annotation-Programming-Model.md | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/Spring-Annotation-Programming-Model.md b/Spring-Annotation-Programming-Model.md index 3a8d3bd..4d9f65e 100644 --- a/Spring-Annotation-Programming-Model.md +++ b/Spring-Annotation-Programming-Model.md @@ -148,8 +148,8 @@ declare a pair of aliased attributes _within_ a single annotation or to declare an alias from one attribute in a custom composed annotation to an attribute in a meta-annotation. -For example, `@ContextConfiguration` from the `spring-test` module is now -declared as follows: +For example, `@ContextConfiguration` from the `spring-test` module is +declared as follows. ```java public @interface ContextConfiguration { @@ -164,6 +164,25 @@ public @interface ContextConfiguration { } ``` +The `locations` attribute is declared as an alias for the `value` +attribute, and vice versa. Consequently, the following declarations +of `@ContextConfiguration` are equivalent. + +```java +@ContextConfiguration("/test-config.xml") +public class MyTests { /* ... */ } +``` + +```java +@ContextConfiguration(value = "/test-config.xml") +public class MyTests { /* ... */ } +``` + +```java +@ContextConfiguration(locations = "/test-config.xml") +public class MyTests { /* ... */ } +``` + Similarly, _composed annotations_ that override attributes from meta-annotations can use `@AliasFor` for fine-grained control over exactly which attributes are overridden within an annotation hierarchy. In fact, it is