Skip to content

Commit c178c9d

Browse files
committed
Merge branch '2.1.x'
2 parents 16f798d + 38d36ab commit c178c9d

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

Diff for: spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix/configuration-metadata.adoc

+45
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,51 @@ is detected even if only a getter is present).
820820
The annotation processor also supports the use of the `@Data`, `@Getter`, and `@Setter`
821821
lombok annotations.
822822

823+
824+
The annotation processor cannot auto-detect default values for ``Enum``s and ``Collections``s.
825+
In the cases where a `Collection` or `Enum` property has a non-empty default value,
826+
<<configuration-metadata-additional-metadata,manual metadata>> should be provided.
827+
828+
Consider the following class:
829+
830+
[source,java,indent=0,subs="verbatim,quotes,attributes"]
831+
----
832+
@ConfigurationProperties(prefix="rabbit")
833+
public class RabbitProperties {
834+
835+
private List<String> addresses = new ArrayList<>(Arrays.asList("a", "b")) ;
836+
837+
private ContainerType = ContainerType.SIMPLE;
838+
839+
// ... getter and setters
840+
841+
public enum ContainerType {
842+
843+
SIMPLE,
844+
845+
DIRECT
846+
847+
}
848+
849+
}
850+
----
851+
852+
In order to document default values for properties in the class above, you could add the following
853+
JSON to <<configuration-metadata-additional-metadata,the manual metadata of the module>>:
854+
855+
[source,json,indent=0]
856+
----
857+
{
858+
"name": "rabbit.addresses",
859+
"defaultValue": "a, b"
860+
},
861+
{
862+
"name": "rabbit.container-type",
863+
"defaultValue": "simple"
864+
}
865+
----
866+
867+
823868
[NOTE]
824869
====
825870
If you are using AspectJ in your project, you need to make sure that the annotation

0 commit comments

Comments
 (0)