Nested Spring configuration (ConfigurationProperties) in records

You don't need @ConfigurationProperties for each nested class. It only for the root class (Foo.class). Then make the Foo as Spring Bean by inserting @Component above the class or put @ConfigurationPropertiesScan on the Application class.