Annotation Type ConfigurationProperties


@Retention(CLASS) @Target({TYPE,METHOD}) public @interface ConfigurationProperties

Binds a group of configuration keys to the setters of a bean.

@Component
@ConfigurationProperties("mail")
public class MailSettings {
    private String host = "localhost";
    private int port = 25;
    public void setHost(String host) { this.host = host; }
    public void setPort(int port) { this.port = port; }
}

Reads mail.host and mail.port, and calls a setter only when its key is set, so a field initializer is the default. The build lists the setters and writes one typed read per setter into the entry point; nothing is discovered at run time. Spring's relaxed binding applies to the setter name: setMaxSize reads mail.max-size when mail.maxSize is not set.

  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Same as value(); Spring accepts either.
    The key prefix, without the trailing dot.
  • Element Details

    • value

      String value
      The key prefix, without the trailing dot.
      Default:
      ""
    • prefix

      String prefix
      Same as value(); Spring accepts either.
      Default:
      ""