Annotation Interface Priority


@Target({TYPE,METHOD}) @Retention(RUNTIME) @Documented public @interface Priority
Specifies the priority of a bean implementation when multiple implementations of the same type are available.

Higher values indicate higher priority. When multiple implementations of the same type exist, the one with the highest priority will be selected for injection.

Example usage:

 @Priority(100)
 public class PreferredImplementation implements Service {
     // Implementation
 }
 
Since:
4.0.0
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    int
    The priority value for the annotated element.
  • Element Details

    • value

      int value
      The priority value for the annotated element.

      Higher values indicate higher priority. When multiple implementations of the same type exist in the container, the one with the highest priority value will be selected for injection.

      There are no predefined minimum or maximum values, but it's recommended to use values that allow for future adjustments (e.g., using values like 100, 200, 300 rather than consecutive numbers).

      Returns:
      the priority value for ordering