diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/AnnotatedClassFinder.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/AnnotatedClassFinder.java index 2e86dfa669..e7330e7a36 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/AnnotatedClassFinder.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/AnnotatedClassFinder.java @@ -41,6 +41,8 @@ public final class AnnotatedClassFinder { private static final Map> cache = Collections .synchronizedMap(new Cache(40)); + private final Class annotationType; + private final ClassPathScanningCandidateComponentProvider scanner; /** @@ -49,6 +51,7 @@ public final class AnnotatedClassFinder { */ public AnnotatedClassFinder(Class annotationType) { Assert.notNull(annotationType, "AnnotationType must not be null"); + this.annotationType = annotationType; this.scanner = new ClassPathScanningCandidateComponentProvider(false); this.scanner.addIncludeFilter(new AnnotationTypeFilter(annotationType)); this.scanner.setResourcePattern("*.class"); @@ -88,8 +91,8 @@ public final class AnnotatedClassFinder { Set components = this.scanner.findCandidateComponents(source); if (!components.isEmpty()) { Assert.state(components.size() == 1, - () -> "Found multiple @SpringBootConfiguration annotated classes " - + components); + () -> "Found multiple @" + this.annotationType.getSimpleName() + + " annotated classes " + components); return ClassUtils.resolveClassName( components.iterator().next().getBeanClassName(), null); }