diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizer.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizer.java index fdc8eebb49..15fe712402 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizer.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizer.java @@ -93,10 +93,7 @@ class PropertyMappingContextCustomizer implements ContextCustomizer { } private Class getRoot(MergedAnnotation annotation) { - while (annotation.getParent() != null) { - annotation = annotation.getParent(); - } - return annotation.getType(); + return annotation.getRoot().getType(); } private String getAnnotationsDescription(Set> annotations) {