application.properties :목록을 @Value로 삽입하는 방법은 무엇입니까?
@Value("${my.list}")
List<Integer> list;
나는이 작업을 위해 다음과 같은 콩이 등록하는 것을 발견 그물에 :
my.list=1,2,3,4
가 나는 @Value
필드에 List
으로이 주입 할 :
@Bean
public ConversionService conversionService() {
return new DefaultConversionService();
}
결과 :
org.springframework.beans.TypeMismatchException: Failed to convert value of type [java.lang.String] to required type [java.util.List];
Caused by: java.lang.NumberFormatException: For input string: "1,2,3,4"
어떻게 든 spring
은 (는) 이것을 목록으로 분석하려고 시도하지 않습니다. 왜?
sp30을 @Value("#{'${my.list}'.split(',')}")
과 함께 사용하는 것이 가능하다는 것을 알고 있습니다. 그러나 나는 분명히 대화 할 필요가없는 해결책을 찾고 있습니다.
스프링 부트를 사용하고 있습니까? –
예'spring-boot'를 사용합니다. 1.3.5 – membersound
시도해 보셨습니까? http://stackoverflow.com/questions/12576156/reading-a-list-from-properties-file-and-load-with-spring-annotation-value –