From 38d36ab18d7a9ed837576bb202a776a07bfc436f Mon Sep 17 00:00:00 2001 From: Madhura Bhave Date: Mon, 12 Aug 2019 17:26:39 -0700 Subject: [PATCH] Document how to add metadata for collection and enum default values Closes gh-12874 --- .../appendix-configuration-metadata.adoc | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-configuration-metadata.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-configuration-metadata.adoc index b07144d7739..af079c66fbc 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-configuration-metadata.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-configuration-metadata.adoc @@ -814,6 +814,51 @@ special handling for collection types (that is detected even if only a getter is The annotation processor also supports the use of the `@Data`, `@Getter`, and `@Setter` lombok annotations. + +The annotation processor cannot auto-detect default values for ``Enum``s and ``Collections``s. +In the cases where a `Collection` or `Enum` property has a non-empty default value, +<> should be provided. + +Consider the following class: + +[source,java,indent=0,subs="verbatim,quotes,attributes"] +---- + @ConfigurationProperties(prefix="rabbit") + public class RabbitProperties { + + private List addresses = new ArrayList<>(Arrays.asList("a", "b")) ; + + private ContainerType = ContainerType.SIMPLE; + + // ... getter and setters + + public enum ContainerType { + + SIMPLE, + + DIRECT + + } + + } +---- + +In order to document default values for properties in the class above, you could add the following +JSON to <>: + +[source,json,indent=0] +---- + { + "name": "rabbit.addresses", + "defaultValue": "a, b" + }, + { + "name": "rabbit.container-type", + "defaultValue": "simple" + } +---- + + [NOTE] ==== If you are using AspectJ in your project, you need to make sure that the annotation