From 9afd6f53e5d39643fc3263b5b837e8fd97ea7b67 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 8 Oct 2018 16:09:14 +0100 Subject: [PATCH] Document need for -parameters compilation with @SpyBean and @Cacheable Closes gh-13945 --- .../src/main/asciidoc/spring-boot-features.adoc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index e6e8ec2468e..6425de7046f 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -6392,6 +6392,11 @@ NOTE: While Spring's test framework caches application contexts between tests an a context for tests sharing the same configuration, the use of `@MockBean` or `@SpyBean` influences the cache key, which will most likely increase the number of contexts. +TIP: If you are using `@SpyBean` to spy on a bean with `@Cachable` methods that refer +to parameter's by name, your application must be compiled with `-parameters`. This +ensures that the parameter names are available to the caching infrastructure once the +bean has been spied upon. + [[boot-features-testing-spring-boot-applications-testing-autoconfigured-tests]]