Annotation Interface ConfigProperties


Declares a class as a prefix-scoped, whole-object config binding target — Juneau's analog of Spring's @ConfigurationProperties.

When a @ConfigProperties-annotated class is materialized through BeanInstantiator, its fields are populated from the Settings chain under prefix() via ConfigPropertiesBinder, and the bound instance is auto-registered into the current BeanStore.

Binding order and lifecycle

The whole-object config bind runs after @Value/@Inject field-and-method injection and before any @PostConstruct method — so a @PostConstruct method observes the fully-bound config fields. Fields that are themselves annotated with @Value or @Inject are left to the injection engine and are never overwritten by config binding, even when a matching prefix.fieldName key exists.

Caller-scoped sources

The bind consults any PropertySource-typed beans in the active BeanStore ahead of the global Settings chain, so a caller can layer overriding or supplementary sources without mutating the shared Settings.get() singleton.

Not inherited

This annotation is not @Inherited: the BeanInstantiator trigger fires only when the exact declared type being instantiated carries the annotation — a subclass or interface implementor of an annotated type does not itself trigger binding or auto-registration.

This is distinct from the ConfigPropertiesBinder nested-field detection, which is inheritance-aware: a field whose declared type is a subclass of an @ConfigProperties-annotated type still triggers nested binding under the enclosing type's prefix, since the annotation lookup there walks the declared field type's class hierarchy rather than requiring an exact-type match.

Example:

@ConfigProperties(prefix = "MyService") public class MyServiceProperties { public String host = "localhost"; public int port = 8080; }

@ConfigProperties and @Value coexist: @Value resolves a single value; @ConfigProperties resolves a whole object. A class can use @Value fields internally and separately be the target of another class's nested @ConfigProperties bind.

See Also:
Since:
10.0.0
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The property-key prefix (no trailing dot).
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    Whether relaxed (camelCase / kebab-case / dotted / SCREAMING_SNAKE_CASE) key matching is enabled.
  • Element Details

    • prefix

      The property-key prefix (no trailing dot).

      Ignored when the annotated type appears as a nested field of another @ConfigProperties type — the enclosing type's prefix (extended with the field name) wins for the nested bind.

      Returns:
      The prefix.
    • relaxed

      boolean relaxed
      Whether relaxed (camelCase / kebab-case / dotted / SCREAMING_SNAKE_CASE) key matching is enabled.

      Ignored when the annotated type appears as a nested field of another @ConfigProperties type — the enclosing type's relaxed flag wins for the nested bind.

      Returns:
      true if relaxed matching is enabled. Defaults to true.
      Default:
      true