我正在以这种方式在spring中配置调度程序任务:
<bean id="someSchedulerTask" class="org.springframework.scheduling.concurrent.ScheduledExecutorTask">
<!-- start after 60 seconds -->
<property name="delay" value="6000"/>
<!-- depends on the enviroment -->
<property name="period" value="${period}"/>
<property name="runnable" ref="myScheduler"/>
</bean>
该属性period
是在某个配置文件中设置的,默认类型好像是String:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'someSchedulerTask' defined in class path resource [context.xml]: Initialization of b
ean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java.lang.String' to required type 'long' for property 'period'; nested exception is ja
va.lang.NumberFormatException: For input string: "period"
我怎么能在这一步从Stirng变成Long??
提前致谢
编辑 占位符配置没有问题,我在另一个 bean 中使用了这个配置文件中的更多值。宣言:
period=30000