'Spring Boot: How to create a composed annotation using @GetMapping?

I'm trying to create a composed annotation the uses @GetMapping, however I can't seem to make it work.

This works (using @RequestMapping):

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@HxRequest
@RequestMapping(
        method = {RequestMethod.GET}
)
public @interface HxGetMapping {
    @AliasFor(annotation = RequestMapping.class, attribute = "value")
    String value();
}

However, using @GetMapping directly does not work (presumably due to @GetMapping only being allowed on methods):

enter image description here

Is the no way to use @GetMapping as a composable annotation?



Solution 1:[1]

As verified in the comments by @RobSpoor, IT CAN'T BE DONE.

But all is not lost, use @RequestMapping to achieve the desired end result:

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@HxRequest
@RequestMapping(
        method = {RequestMethod.GET}
)
public @interface HxGetMapping {
    @AliasFor(annotation = RequestMapping.class, attribute = "value")
    String value();
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 checketts