Skip to content

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

Closed
@wilkinsona

Description

@wilkinsona
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...

}

Activity

added this to the 3.0.x milestone on Nov 17, 2022
self-assigned this
on Nov 18, 2022
modified the milestones: 3.0.x, 3.0.0 on Nov 18, 2022
wilkinsona

wilkinsona commented on Nov 18, 2022

@wilkinsona
MemberAuthor

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.

mhalbritter

mhalbritter commented on Nov 18, 2022

@mhalbritter
Contributor

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

siddhsql

siddhsql commented on May 24, 2024

@siddhsql
scottfrederick

scottfrederick commented on May 24, 2024

@scottfrederick
siddhsql

siddhsql commented on May 24, 2024

@siddhsql

3 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @scottfrederick@bclozel@philwebb@wilkinsona@mhalbritter

      Issue actions

        Documentation for nested configuration properties in a native image uses `@NestedConfigurationProperty` too widely · Issue #33239 · spring-projects/spring-boot