Before time ,one annotation attribute only supports one alias ,you can only do like this:

    @Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.TYPE})
    @Retention(RetentionPolicy.RUNTIME)
    public @interface Test1 {
        String test1() default "test1";
    }

    @Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.TYPE})
    @Retention(RetentionPolicy.RUNTIME)
    public @interface Test2 {
        String test2() default "test2";
    }

    @Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.TYPE})
    @Retention(RetentionPolicy.RUNTIME)
    @Test1
    @Test2
    public @interface Test3 {

        @AliasFor(annotation = Test1.class, attribute = "test1")
        String test3() default "test3";

        @AliasFor(annotation = Test2.class, attribute = "test2")
        String test4() default "test4";
    }

But now ,you can do this more easily:

    @Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.TYPE})
    @Retention(RetentionPolicy.RUNTIME)
    @Test1
    @Test2
    public @interface Test3 {

        @AliasFor(annotation = Test1.class, attribute = "test1")
        @AliasFor(annotation = Test2.class, attribute = "test2")
        String test3() default "test3";
    }

Moreover, the mutual aliasing of different attributes in the same annotation can break the original limitation (although this kind of use scenario is less):

    @Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.TYPE})
    @Retention(RetentionPolicy.RUNTIME)
    public @interface Test4 {

        @AliasFor("test2")
        @AliasFor("test3")
        String test1() default "test";

        @AliasFor("test1")
        @AliasFor("test3")
        String test2() default "test";

        @AliasFor("test1")
        @AliasFor("test2")
        String test3() default "test";
    }

Combine examples above, you can use @AliasFors like this:

    @Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.TYPE})
    @Retention(RetentionPolicy.RUNTIME)
    public @interface Test5 {

        @AliasFor("test2")
        @AliasFor("test3")
        String test1() default "test1";

        @AliasFor("test1")
        @AliasFor("test3")
        String test2() default "test1";

        @AliasFor("test1")
        @AliasFor("test2")
        String test3() default "test1";
    }

    @Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.TYPE})
    @Retention(RetentionPolicy.RUNTIME)
    @Test5
    public @interface Test6 {

        @AliasFor("test2")
        @AliasFor("test3")
        String test1() default "test2";

        @AliasFor("test1")
        @AliasFor("test3")
        String test2() default "test2";

        @AliasFor(annotation = Test5.class)
        @AliasFor("test1")
        @AliasFor("test2")
        String test3() default "test2";
    }

    @Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.TYPE})
    @Retention(RetentionPolicy.RUNTIME)
    @Test6
    public @interface Test7 {

        @AliasFor(annotation = Test6.class)
        String test3() default "test3";
    }

    @Test7(test3 = "override the method")
    public static class Element4 {
    }

    @Test
    public void test3() {
        Test5 test5 = AnnotatedElementUtils.getMergedAnnotation(Element4.class, Test5.class);
        Test6 test6 = AnnotatedElementUtils.getMergedAnnotation(Element4.class, Test6.class);
        System.out.println(test5.toString());
        System.out.println(test6.toString());
        assertEquals("override the method", test6.test1());
        assertEquals("override the method", test6.test2());
        assertEquals("override the method", test6.test3());
        assertEquals("override the method", test5.test1());
        assertEquals("override the method", test5.test2());
        assertEquals("override the method", test5.test3());
    }

For more details, please read org.springframework.core.annotation.AlisforsTests.

Comment From: sbrannen

I've edited your comment to improve the formatting. You might want to check out this Mastering Markdown guide for future reference.

Comment From: loongs-zhang

Thank you for your valuable suggestions, and I would like to ask when the multi-alias feature will be available.

---Original--- From: "Sam Brannen"<notifications@github.com> Date: Mon, Oct 5, 2020 18:39 PM To: "spring-projects/spring-framework"<spring-framework@noreply.github.com>; Cc: "Author"<author@noreply.github.com>;"dragon-zhang"<1936978077@qq.com>; Subject: Re: [spring-projects/spring-framework] Dev 5.3.x Annotation Attribute Supporting Multiple Aliases Tag (#25857)

I've edited your comment to improve the formatting. You might want to check out this Mastering Markdown guide for future reference.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

Comment From: loongs-zhang

Thank you again for taking the time to review these submissions. I'm sorry to ask such a reckless question.

---Original--- From: "Sam Brannen"<notifications@github.com> Date: Mon, Oct 5, 2020 18:39 PM To: "spring-projects/spring-framework"<spring-framework@noreply.github.com>; Cc: "Author"<author@noreply.github.com>;"dragon-zhang"<1936978077@qq.com>; Subject: Re: [spring-projects/spring-framework] Dev 5.3.x Annotation Attribute Supporting Multiple Aliases Tag (#25857)

I've edited your comment to improve the formatting. You might want to check out this Mastering Markdown guide for future reference.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

Comment From: sbrannen

Team Decision: after thoughtful consideration, the team has decided not to introduce support for @AliasFor as a repeatable annotation due to the complexity it adds to the already complex MergedAnnotations API and implementation.

In any case, thank you for the contribution. We realize you put considerable effort into the PR and apologize for any misunderstanding in https://github.com/spring-projects/spring-framework/pull/25592#issuecomment-674548229.

Comment From: loongs-zhang

Thank you for your encouragement and I will continue to contribute code for other features to spring.

---Original--- From: "Sam Brannen"<notifications@github.com> Date: Wed, Nov 4, 2020 23:33 PM To: "spring-projects/spring-framework"<spring-framework@noreply.github.com>; Cc: "Author"<author@noreply.github.com>;"dragon-zhang"<1936978077@qq.com>; Subject: Re: [spring-projects/spring-framework] Support multiple aliases via @AliasFor (#25857)

Team Decision: after thoughtful consideration, the team has decided not to introduce support for @AliasFor as a repeatable annotation due to the complexity it adds to the already complex MergedAnnotations API and implementation.

In any case, thank you for the contribution. We realize you put considerable effort into the PR and apologize for any misunderstanding in #25592 (comment).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.