@@ -8733,16 +8733,55 @@ assume that you are creating a starter for "acme" and that you name the auto-con
8733
8733
module `acme-spring-boot-autoconfigure` and the starter `acme-spring-boot-starter`. If
8734
8734
you only have one module that combines the two, name it `acme-spring-boot-starter`.
8735
8735
8736
- Also, if your starter provides configuration keys, use a unique namespace for them. In
8736
+
8737
+
8738
+ [[boot-features-custom-starter-configuration-keys]]
8739
+ ==== Configuration keys
8740
+ If your starter provides configuration keys, use a unique namespace for them. In
8737
8741
particular, do not include your keys in the namespaces that Spring Boot uses (such as
8738
8742
`server`, `management`, `spring`, and so on). If you use the same namespace, we may modify
8739
- these namespaces in the future in ways that break your modules.
8743
+ these namespaces in the future in ways that break your modules. As a rule of thumb,
8744
+ prefix all your keys with a namespace that you own (e.g. `acme`).
8745
+
8746
+ Make sure that configuration keys are documented by adding field javadoc for each
8747
+ property, as shown in the following example:
8748
+
8749
+ [source,java,indent=0]
8750
+ ----
8751
+ @ConfigurationProperties("acme")
8752
+ public class AcmeProperties {
8753
+
8754
+ /**
8755
+ * Whether to check the location of acme resources.
8756
+ */
8757
+ private boolean checkLocation = true;
8758
+
8759
+ /**
8760
+ * Timeout for establishing a connection to the acme server.
8761
+ */
8762
+ private Duration loginTimeout = Duration.ofSeconds(3);
8763
+
8764
+ // getters & setters
8765
+
8766
+ }
8767
+ ----
8768
+
8769
+ Here are some rules we follow internally to make sure descriptions are consistent:
8770
+
8771
+ * Do not start the description by "The" or "A".
8772
+ * For `boolean` types, start the description with "Whether" or "Enable".
8773
+ * For collection-based types, start the description with "Comma-separated list"
8774
+ * Use `java.time.Duration` rather than `long` and describe the default unit if it differs
8775
+ from milliseconds, e.g. "If a duration suffix is not specified, seconds will be used".
8776
+ * Do not provide the default value in the description unless it has to be determined at
8777
+ runtime.
8740
8778
8741
8779
Make sure to
8742
8780
<<appendix.adoc#configuration-metadata-annotation-processor,trigger meta-data
8743
8781
generation>> so that IDE assistance is available for your keys as well. You may want to
8744
- review the generated meta-data (`META-INF/spring-configuration-metadata.json`) to make
8745
- sure your keys are properly documented.
8782
+ review the generated metadata (`META-INF/spring-configuration-metadata.json`) to make
8783
+ sure your keys are properly documented. Using your own starter in a compatible IDE is
8784
+ also a good idea to validate that quality of the metadata.
8746
8785
8747
8786
8748
8787
0 commit comments