Skip to content

Commit a1f32bb

Browse files
committed
Merge branch '2.1.x'
Closes gh-17603
2 parents c82e33e + 30fe106 commit a1f32bb

File tree

1 file changed

+43
-4
lines changed

1 file changed

+43
-4
lines changed

spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8733,16 +8733,55 @@ assume that you are creating a starter for "acme" and that you name the auto-con
87338733
module `acme-spring-boot-autoconfigure` and the starter `acme-spring-boot-starter`. If
87348734
you only have one module that combines the two, name it `acme-spring-boot-starter`.
87358735

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
87378741
particular, do not include your keys in the namespaces that Spring Boot uses (such as
87388742
`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.
87408778

87418779
Make sure to
87428780
<<appendix.adoc#configuration-metadata-annotation-processor,trigger meta-data
87438781
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.
87468785

87478786

87488787

0 commit comments

Comments
 (0)