Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation for nested configuration properties in a native image uses @NestedConfigurationProperty too widely #33239

Closed
wilkinsona opened this issue Nov 17, 2022 · 2 comments
Assignees
Labels
type: documentation A documentation update
Milestone

Comments

@wilkinsona
Copy link
Member

The documentation example looks like this:

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

    private String name;

    @NestedConfigurationProperty
    private Nested nested = new Nested();

    // getters / setters...

    public static class Nested {

        private int number;

        // getters / setters...

    }

}

In this case, @NestedConfigurationProperty isn't required as Nested is already nested within MyProperties. It would be required if the code were structure like this:

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

    private String name;

    @NestedConfigurationProperty
    private Nested nested = new Nested();

    // getters / setters...

}

public class Nested {

    private int number;

    // getters / setters...

}
@wilkinsona
Copy link
Member Author

wilkinsona commented Nov 18, 2022

Thanks, @mhalbritter. Sorry, I wasn't very clear above and those changes aren't what I had in mind. Rather than removing @NestedConfigurationProperty I think we need to update the example so that it is required. We can then build on that in #33235 to add some further examples with records and Kotlin data classes.

@wilkinsona wilkinsona reopened this Nov 18, 2022
@mhalbritter
Copy link
Contributor

Ah, I see. I'll add an example showing when @NestedConfigurationProperties is needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: documentation A documentation update
Projects
None yet
Development

No branches or pull requests

2 participants