Commit 6710c057 authored by Stephane Nicoll's avatar Stephane Nicoll

Document `DeprecatedConfigurationProperty`

Closes gh-5118
parent a1fefb15
...@@ -222,6 +222,40 @@ the `deprecation` element. This is still supported in a deprecated fashion and s ...@@ -222,6 +222,40 @@ the `deprecation` element. This is still supported in a deprecated fashion and s
be used. If no reason and replacement are available, an empty `deprecation` object should be be used. If no reason and replacement are available, an empty `deprecation` object should be
set. set.
Deprecation can also be specified declaratively in code by adding the
`@DeprecatedConfigurationProperty` annotation to the getter exposing the deprecated
property. For instance, let's assume the `app.foo.target` property was confusing and
was renamed to `app.foo.name`
[source,java,indent=0]
----
@ConfigurationProperties("app.foo")
public class FooProperties {
private String name;
public String getName() { ... }
public void setName(String name) { ... }
@DeprecatedConfigurationProperty(replacement = "app.foo.name")
@Deprecated
public String getTarget() {
return getName();
}
@Deprecated
public void setTarget(String target) {
setName(target);
}
}
----
The code above makes sure that the deprecated property still works (delegating
to the `name` property behind the scenes). Once the `getTarget` and `setTarget`
methods can be removed from your public API, the automatic deprecation hint in the
meta-data will go away as well.
[[configuration-metadata-hints-attributes]] [[configuration-metadata-hints-attributes]]
==== Hint Attributes ==== Hint Attributes
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment