これは、 @Component クラスに日付を挿入しようとしている方法です。
@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")'