Hi,

I recently upgraded to Spring Boot 3.2.0 and i think i have found a regression with properties binding within a Map, which is the destination of every properties. Everything worked fine with Spring Boot 3.1.6 but it now failed to start the application with Spring Boot 3.2.x Here is a sample to demonstrate :

public class FooConfigProperties {

    private Map<String, List<ObjectX>> list;

    // Getter, Setters

}

.

public class ObjectX {

  private String cool;
  private String warm;
  private String cold;

 // Constructor, getter, setter ...
}

.

@AutoConfiguration
@EnableConfigurationProperties
public class AutoConfigureExemple {

    @Bean
    @ConfigurationProperties(prefix = "foo.foo1")
    FooConfigProperties fooConfigProperties() {
        return new FooConfigProperties();
    }

}

Here is an application.yml file used for the configuration. SpringBoot Spring Boot 3.2.0 failed to bind properties of a Map

With Spring Boot 3.2.x, the application failed to start with such error. Property: foo.foo1.list.step1[0].cool Value: "qw" Origin: class path resource [application.yml] Reason: The elements [foo.foo1.list.step1[0].cool,foo.foo1.list.step1[1].cool,... were left unbound.

Comment From: wilkinsona

Can you please turn the partial snippets and screenshots above into a small sample project that we can unzip or clone and then run to reproduce the problem?

Comment From: philwebb

You might also want to check that you are compiling with -parameters (see https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.2-Release-Notes#parameter-name-discovery)

Comment From: rajmetti

Added the specified files in same format for spring boot 3.2.0 version. I'm able to get the output. repo link: https://github.com/rajmetti/sb_issue_39373

Comment From: livk-cloud

Normal output using SpringBoot 3.2.2

@SpringBootApplication
public class App {
    @Bean
    @ConfigurationProperties(prefix = "foo.foo1")
    FooConfig fooConfig(){
        return new FooConfig();
    }

    @Bean
    ApplicationRunner applicationRunner(FooConfig fooConfig){
        return args -> fooConfig.getList().values().forEach(System.out::println);
    }

    public static void main(String[] args) {
        SpringApplication.run(App.class, args);
    }
}

SpringBoot Spring Boot 3.2.0 failed to bind properties of a Map

SpringBoot Spring Boot 3.2.0 failed to bind properties of a Map

Comment From: Lmgrto

Hello, sorry about the delay, i had some issues to reproduce the issue, but with the help of the exemple of @rajmetti i found why and i found a workaround. I found that the error is present because FooConfigProperties and ObjectX classes are in a no spring project. And the mapping doesn't work anymore with Spring Boot 3.2.X. For now, i have duplicate the 2 classes (FooConfigProperties and ObjectX) in the Spring Boot project and make a process to convert it for the no spring project.

I made two sample projects that reflect more my configuration. https://github.com/Lmgrto/SecondProjectConfig as the no spring project which contains FooConfigProperties and ObjectX https://github.com/Lmgrto/demoConfig as the spring project which contains the Configuration Bean

Comment From: wilkinsona

Thanks, @Lmgrto. As @philwebb suspected, the problem's due to the code being compiled without -parameters. That resulted in a warning with Spring Boot 3.1 and Spring Framework 6.0. It fails with Spring Boot 3.2 and Spring Framework 6.1 due to a change in the latter. If you cannot compiled the external code with -parameters, then creating classes in your application over which you have complete control for the purposes of configuration property binding is the right thing to do.

Comment From: Siddhant791

I'm facing the same issue, Can springboot team can help me with this