I want to group some of my annotation to use them in more simple way. I read this document about @Stereotype annotation. I want to achive something like this:
@Stereotype
@AnnotationA
@AnnotationB
@Annotationc
@Target(...)
@Retention(...)
public @interface GroupAnnotation {
}
@GroupAnnotation
class X {}
@GroupAnnotation
class Y {}
But whenever I tried to use this annotation I got the following error message in IntelliJ:
Cannot resolve symbol 'Stereotype'
So is there any way to use this annotation in spring? Or do u have any alternatives of grouping annotations?
I'm using spring 2.7.1 and Java 11.
--- UPDATE ---
My real life scenario related to use @JsonFormat annotation. I wanted to setup it in one place and use it in many cases.
Combining Spring's annotations
Annotation
@Stereotype
is a part of Java EE (Jakarta EE) world, and it's not available in Spring. More over, it's not needed in Spring.Assuming that you need to combine several annotations provided by Spring, here's how it can be done:
A more concrete example:
By the way, here's the right place to go when you need Spring documentation:
Combining Jackson's annotations
In order to create a custom multi-annotation from several Jacksons annotations, you need to apply a special meta-annotation
@JacksonAnnotationsInside
provided by Jackson:Example: