I could add this as a comment, but I wanted to add formatted code to explain my point of view, and that is why I am adding an explicit answer.
Adding to what you said, you can really use your specific meta annotation inside Spring also in the following lines:
Override @Specific with Spring specific annotation org.springframework.beans.factory.annotation.Qualifier as follows:
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Primary; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @Qualifier @Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) @Primary public @interface Specific { }
I also noted the annotation with the @Primary annotation.
With this in place, your old code should work:
@Specific class DefaultImpl implements A {}
source share