Annotation Interface Env


@Retention(RUNTIME) @Target({FIELD,METHOD}) public @interface Env
Specifies that a configuration field or method can be overridden by an environment variable.

Used inside @Overwrite to declare an environment variable source, e.g.:


 @Overwrite(env = @Env("MY_APP_HOST"))
 private String host;
 

If no explicit name is provided (i.e. @Env()), the variable name is derived automatically from the class name and field name in UPPER_CASE format: CLASSNAME_FIELDNAME. For example, a field myCoolVariable in class AppConfig would look for the environment variable APPCONFIG_MYCOOLVARIABLE.

See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The environment variable name to read.
  • Element Details

    • value

      String value
      The environment variable name to read. Leave empty to use the auto-derived name.
      Default:
      ""