Skip to content

Improve exception message for mixed explicit and implicit aliases with @AliasFor #24168

@BartoszCoyote

Description

@BartoszCoyote

I just upgraded Spring Boot version to 2.2.2 from 2.1.8 and noticed a weird exception:

Caused by: org.springframework.core.annotation.AnnotationConfigurationException: Attribute 'value' in annotation [en.example.package.PostApi] must be declared as an @AliasFor 'path', not 'path'.

Whole code for my custom annotation.

public @interface PostApi {

    @AliasFor(annotation = ResponseStatus.class, attribute = "code") 
    HttpStatus status() default HttpStatus.OK;

    @AliasFor("value") 
    String[] path() default {};

    @AliasFor(annotation = RequestMapping.class, attribute = "path") 
    String[] value() default {};

    @AliasFor(annotation = RequestMapping.class, attribute = "consumes") 
    String[] consumes() default { MediaType.APPLICATION_JSON_VALUE };

}

Any ideas what is going on?

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions