Spring 使用@Value注释注入日期
这就是我试图将日期注入@Component类的方式Spring 使用@Value注释注入日期,spring,date,annotations,code-injection,Spring,Date,Annotations,Code Injection,这就是我试图将日期注入@Component类的方式 @Value("${new java.text.SimpleDateFormat(\"yyyyMMdd\").parse(\"${PROP_DATE}\")}") Date myDate; 在属性文件中将日期指定为字符串: PROP_DATE=20110421 我得到这个错误。我做错了什么?是否有其他方法注入日期属性?谢谢 Exception in thread "main" org.springframework.beans.factor
@Value("${new java.text.SimpleDateFormat(\"yyyyMMdd\").parse(\"${PROP_DATE}\")}")
Date myDate;
在属性文件中将日期指定为字符串:
PROP_DATE=20110421
我得到这个错误。我做错了什么?是否有其他方法注入日期属性?谢谢
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.simpleDataFormat(\'yyyyMMdd\”).parse(\“${PROP\u DATE}\”)}
处理带有spEL的进程值