diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java index dc822d85d8b9..17e556315972 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java @@ -581,7 +581,11 @@ private InjectionMetadata buildAutowiringMetadata(Class clazz) { } return; } - if (!method.getDeclaringClass().isRecord() && method.getParameterCount() == 0) { + if (method.getParameterCount() == 0) { + if (method.getDeclaringClass().isRecord()) { + // Annotations on the compact constructor arguments made available on accessors, ignoring. + return; + } if (logger.isInfoEnabled()) { logger.info("Autowired annotation should only be used on methods with parameters: " + method);