Annotation Interface Value


Resolves a configuration value into a constructor parameter, setter, or field.

The value() string is passed through Juneau's VarResolver (so ${...} / $P{...} placeholders are expanded against Settings.get()), then coerced to the target Java type via Settings.toType(String, Class).

Examples:

// Field injection with default. @Value("${db.timeout.ms:5000}") private int timeoutMs; // Constructor-parameter injection. @Inject public OrdersResource( @Value("${app.name:orders}") String appName, @Value("${app.start}") Instant start ) { ... }

Resolution order:
  1. Thread-local override (Settings.setLocal)
  2. Global override (Settings.setGlobal)
  3. Property sources in reverse insertion order — this is where Juneau Config, Spring Environment, and any other registered PropertySource participate.
  4. System properties
  5. System environment variables

Spring's org.springframework.beans.factory.annotation.Value annotation is honored identically via FQN-based detection in JsrSupport; no compile-time Spring dependency is introduced in juneau-commons.

Notes:
  • @Value and @Inject on the same site is invalid and throws a BeanCreationException. @Value resolves strings/primitives; @Inject resolves beans.
  • If the expression resolves to null and the target type is a primitive, a BeanCreationException is thrown. For reference types, null is injected.
See Also:
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The configuration expression.
  • Element Details

    • value

      The configuration expression.

      Typically uses the ${key} or ${key:default} placeholder syntax that is routed through VarResolver and Settings. Plain literals (no $) are passed through unchanged and still type-coerced.

      Returns:
      The configuration expression.