File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
spring-boot-docs/src/main/asciidoc Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -222,6 +222,40 @@ the `deprecation` element. This is still supported in a deprecated fashion and s
222
222
be used. If no reason and replacement are available, an empty `deprecation` object should be
223
223
set.
224
224
225
+ Deprecation can also be specified declaratively in code by adding the
226
+ `@DeprecatedConfigurationProperty` annotation to the getter exposing the deprecated
227
+ property. For instance, let's assume the `app.foo.target` property was confusing and
228
+ was renamed to `app.foo.name`
229
+
230
+ [source,java,indent=0]
231
+ ----
232
+ @ConfigurationProperties("app.foo")
233
+ public class FooProperties {
234
+
235
+ private String name;
236
+
237
+ public String getName() { ... }
238
+
239
+ public void setName(String name) { ... }
240
+
241
+ @DeprecatedConfigurationProperty(replacement = "app.foo.name")
242
+ @Deprecated
243
+ public String getTarget() {
244
+ return getName();
245
+ }
246
+
247
+ @Deprecated
248
+ public void setTarget(String target) {
249
+ setName(target);
250
+ }
251
+ }
252
+ ----
253
+
254
+ The code above makes sure that the deprecated property still works (delegating
255
+ to the `name` property behind the scenes). Once the `getTarget` and `setTarget`
256
+ methods can be removed from your public API, the automatic deprecation hint in the
257
+ meta-data will go away as well.
258
+
225
259
226
260
[[configuration-metadata-hints-attributes]]
227
261
==== Hint Attributes
You can’t perform that action at this time.
0 commit comments