2
이것은 @Component 클래스에 날짜를 주입하는 방법입니다. 날짜는 속성의 문자열로 지정@Value annotation을 사용하여 날짜를 입력하십시오.
@Value("${new java.text.SimpleDateFormat(\"yyyyMMdd\").parse(\"${PROP_DATE}\")}")
Date myDate;
파일 :
PROP_DATE=20110421
나는이 오류가 발생합니다. 내가 도대체 뭘 잘못하고있는 겁니까? Date 속성을 삽입하는 다른 방법이 있습니까? 감사.
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ccc': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: java.util.Date aaa.bbb.ccc.myDate; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'new java.text.SimpleDateFormat("yyyyMMdd").parse("20110421")'
와 공정 값에 대한 사용
#{new java.text.SimpleDateFormat(\"yyyyMMdd\").parse(\"${PROP_DATE}\")}
. 고맙습니다. –