2017-11-13 20 views
0
내가 그 아래 같은 속성을 갖고 싶어

의지도를 가지고 봄 속성 파일을 읽고 싶은 나의 설정 클래스에서 이상과 같은 코드를 사용지도내가지도

propertymap = { 
    key1:'{subkey1:'subvalue1',subkey2:'subvalue2'}', 
    key2:'{subkey3:'subvalue3',subkey4:'subvalue4'}' } 

@Value("#{${propertymap}}") 
private Map<String,Map<String,String>> propertymap; 

의지도하지만 오류가 발생했습니다. 이 일을 할 수있는 방법이 있으면 알려주십시오.

Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.util.Map nested exception is org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.expression.spel.SpelParseException: EL1043E:(pos 17): Unexpected token. Expected 'rcurly(})' but was 'identifier' 
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573) 
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) 
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331) 

답변

0

는 난 그냥 제거했다, 방법을 볼 수있는 '키

propertymap = { 
    key1:{ 
     subkey1:'subvalue1', 
     subkey2:'subvalue2' 
    }, 
    key2:{ 
     subkey3:'subvalue3', 
     subkey4:'subvalue4' 
    } 
} 

후 코드가 그것을 집어 들고 아래

@Value("#{${propertymap}}") 
private Map<String,Map<String,String>> propertymap;