Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 使用@Value注释注入日期_Spring_Date_Annotations_Code Injection - Fatal编程技术网

Spring 使用@Value注释注入日期

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

这就是我试图将日期注入@Component类的方式

@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的进程值