Skip to content

Commit

Permalink
Revert "Remove unneeded NestedConfigurationProperty"
Browse files Browse the repository at this point in the history
This reverts commit 8048e2d.
  • Loading branch information
mhalbritter committed Nov 18, 2022
1 parent 8048e2d commit 5c10ae2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
Expand Up @@ -6,10 +6,12 @@
[[native-image.advanced.nested-configuration-properties]]
=== Nested Configuration Properties
Reflection hints are automatically created for configuration properties by the Spring ahead-of-time engine.
Nested configuration properties, however, *must* be annotated with `@NestedConfigurationProperty`, otherwise they won't be detected and will not be bindable.

include::code:MyProperties[]

The example above produces configuration properties for `my.properties.name` and `my.properties.nested.number`.
Without the `@NestedConfigurationProperty` annotation on the `nested` field, the `my.properties.nested.number` property would not be bindable in a native image.

NOTE: Please use public getters and setters, otherwise the properties will not be bindable.

Expand Down
Expand Up @@ -17,12 +17,14 @@
package org.springframework.boot.docs.nativeimage.advanced.nestedconfigurationproperties;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;

@ConfigurationProperties(prefix = "my.properties")
public class MyProperties {

private String name;

@NestedConfigurationProperty
private Nested nested = new Nested();

// @fold:on // getters / setters...
Expand Down

0 comments on commit 5c10ae2

Please sign in to comment.