0
some.property=1,2,3,4,5

@Bean
public ConversionService conversionService() {
    return new DefaultConversionService();
}

@Value("${some.property}")
final List<Integer> ints;

with this setup I'm getting Caused by: java.lang.NumberFormatException: For input string: "1,2,3,4,5"

Question:

  1. Why it treats property as String.class and ignores explicit class type List<Integer>?
  2. Is there a way to convert to correct List<Integer> without implementing custom ConversionService.convert method?
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.6.6</version>
</parent>
lpkej
  • 445
  • 6
  • 23

0 Answers0