Annotation Interface DefaultImplementation

@Documented @Retention(RUNTIME) @Target(TYPE) @Inherited public @interface DefaultImplementation

An annotation to apply to an interface to indicate which implementation is the default implementation.

When a bean is looked up and if there are multiple possible candidates with no concrete Primary this annotation will impact bean selection by selecting the default implementation.

It should be noted that Primary and Ordered take precedence over this an annotation and a fallback to the default implementation only occurs if no primary candidate can be established.

Note that this annotation also has an impact on bean replacement via Replaces to another class to allow the replacement of an implementation that isn't accessible due to visibility restrictions.

For example:

 public interface SomeInterface {


 class MyImpl implements SomeInterface {


 class OtherImpl implements SomeInterface {


In the above example the OtherImpl bean will replace the MyImpl bean because the class in the Replaces annotation has a default implementation.

James Kleeh
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
  • Element Details

    • value

      @AliasFor(member="name") Class<?> value
      The bean type that is the default implementation
    • name

      String name
      The fully qualified bean type name that is the default implementation