Given the following composed @ContentRespBody
annotation:
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@ResponseBody
public @interface ContentRespBody {
@AliasFor(annotation = ResponseBody.class)
Class<? extends ResultForm> value() default ContentResultForm.class;
}
Regarding the meta-annotation @ResponseBody
, version 5.0.7 will not report an error, but when upgrading to version 5.2.4, it will report an error.
Is this a bug or an expected result?
Caused by: org.springframework.core.annotation.AnnotationConfigurationException: Attribute 'value' in annotation [com.augurit.agcloud.meta.util.annotations.ContentRespBody] is declared as an @AliasFor nonexistent attribute 'value' in annotation [org.springframework.web.bind.annotation.ResponseBody]. at org.springframework.core.annotation.AnnotationTypeMapping.resolveAliasTarget(AnnotationTypeMapping.java:160) ~[spring-core-5.2.4.RELEASE.jar:5.2.4.RELEASE] at org.springframework.core.annotation.AnnotationTypeMapping.resolveAliasTarget(AnnotationTypeMapping.java:131) ~[spring-core-5.2.4.RELEASE.jar:5.2.4.RELEASE] at org.springframework.core.annotation.AnnotationTypeMapping.resolveAliasedForTargets(AnnotationTypeMapping.java:123) ~[spring-core-5.2.4.RELEASE.jar:5.2.4.RELEASE] at org.springframework.core.annotation.AnnotationTypeMapping.
(AnnotationTypeMapping.java:100) ~[spring-core-5.2.4.RELEASE.jar:5.2.4.RELEASE] at org.springframework.core.annotation.AnnotationTypeMappings.addIfPossible(AnnotationTypeMappings.java:116) ~[spring-core-5.2.4.RELEASE.jar:5.2.4.RELEASE] at org.springframework.core.annotation.AnnotationTypeMappings.addAllMappings(AnnotationTypeMappings.java:75) ~[spring-core-5.2.4.RELEASE.jar:5.2.4.RELEASE] at org.springframework.core.annotation.AnnotationTypeMappings. (AnnotationTypeMappings.java:68) ~[spring-core-5.2.4.RELEASE.jar:5.2.4.RELEASE] at org.springframework.core.annotation.AnnotationTypeMappings. (AnnotationTypeMappings.java:46) ~[spring-core-5.2.4.RELEASE.jar:5.2.4.RELEASE] at org.springframework.core.annotation.AnnotationTypeMappings$Cache.createMappings(AnnotationTypeMappings.java:251) ~[spring-core-5.2.4.RELEASE.jar:5.2.4.RELEASE] at java.util.concurrent.ConcurrentMap.computeIfAbsent(ConcurrentMap.java:324) ~[na:1.8.0_102] at org.springframework.core.annotation.AnnotationTypeMappings$Cache.get(AnnotationTypeMappings.java:247) ~[spring-core-5.2.4.RELEASE.jar:5.2.4.RELEASE] at org.springframework.core.annotation.AnnotationTypeMappings.forAnnotationType(AnnotationTypeMappings.java:204) ~[spring-core-5.2.4.RELEASE.jar:5.2.4.RELEASE] at org.springframework.core.annotation.AnnotationTypeMappings.forAnnotationType(AnnotationTypeMappings.java:186) ~[spring-core-5.2.4.RELEASE.jar:5.2.4.RELEASE] at org.springframework.core.annotation.AnnotationTypeMappings.forAnnotationType(AnnotationTypeMappings.java:173) ~[spring-core-5.2.4.RELEASE.jar:5.2.4.RELEASE] at org.springframework.core.annotation.TypeMappedAnnotation.of(TypeMappedAnnotation.java:634) ~[spring-core-5.2.4.RELEASE.jar:5.2.4.RELEASE] at org.springframework.core.annotation.MergedAnnotation.of(MergedAnnotation.java:596) ~[spring-core-5.2.4.RELEASE.jar:5.2.4.RELEASE] at org.springframework.core.type.classreading.MergedAnnotationReadingVisitor.visitEnd(MergedAnnotationReadingVisitor.java:96) ~[spring-core-5.2.4.RELEASE.jar:5.2.4.RELEASE] at org.springframework.asm.ClassReader.readElementValues(ClassReader.java:2985) ~[spring-core-5.2.4.RELEASE.jar:5.2.4.RELEASE] at org.springframework.asm.ClassReader.readMethod(ClassReader.java:1393) ~[spring-core-5.2.4.RELEASE.jar:5.2.4.RELEASE] at org.springframework.asm.ClassReader.accept(ClassReader.java:718) ~[spring-core-5.2.4.RELEASE.jar:5.2.4.RELEASE] at org.springframework.asm.ClassReader.accept(ClassReader.java:401) ~[spring-core-5.2.4.RELEASE.jar:5.2.4.RELEASE] at org.springframework.core.type.classreading.SimpleMetadataReader. (SimpleMetadataReader.java:50) ~[spring-core-5.2.4.RELEASE.jar:5.2.4.RELEASE] at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:103) ~[spring-core-5.2.4.RELEASE.jar:5.2.4.RELEASE] at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:123) ~[spring-core-5.2.4.RELEASE.jar:5.2.4.RELEASE] at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.__scanCandidateComponents(ClassPathScanningCandidateComponentProvider.java:430) ~[spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE] ... 23 common frames omitted
Comment From: sbrannen
That is the expected behavior, since ResponseBody
in fact does not declare an attribute named value
.
Thus, annotating the value
attribute in your custom annotation with @AliasFor(annotation = ResponseBody.class)
is a configuration error.
If you do not see an error for that in Spring Framework 5.0.7, that simply means that the error detection has improved in Spring Framework 5.2.
Comment From: 929404097
That is the expected behavior, since
ResponseBody
in fact does not declare an attribute namedvalue
.Thus, annotating the
value
attribute in your custom annotation with@AliasFor(annotation = ResponseBody.class)
is a configuration error.If you do not see an error for that in Spring Framework 5.0.7, that simply means that the error detection has improved in Spring Framework 5.2.
thank you