[英]Configure Spring Bean using XML through Property other than String (using Properties File)
I have a Spring Bean defined as: 我有一个定义为:
<bean id="loyaltyPointsExpiringJobTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<property name="name" value="Loyalty Points Expiring Job Trigger" />
<property name="jobDetail" ref="loyaltyPointsExpiringJobDetail" />
<property name="cronExpression" value="${prop.loyalty.expiring.points.job.cron}"/>
<property name="timeZone" value="${prop.loyalty.expiring.points.timezone}"/>
</bean>
However, the property prop.loyalty.expiring.points.timezone
is causing TypeMismatchException
with the message: 但是,属性prop.loyalty.expiring.points.timezone
导致TypeMismatchException
与以下消息:
org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java.lang.String' to required type 'java.util.TimeZone' for property 'timeZone'; org.springframework.beans.TypeMismatchException:无法将类型“ java.lang.String”的属性值转换为属性“ timeZone”的必需类型“ java.util.TimeZone”; nested exception is java.lang.IllegalArgumentException: Invalid time zone specification '${prop.loyalty.expiring.points.timezone}' 嵌套异常为java.lang.IllegalArgumentException:无效的时区规范'$ {prop.loyalty.expiring.points.timezone}'
Please guide. 请指导。
这很简单,您可能需要为timeZone
对象定义一个bean,并找出使用字符串的构造函数,并传递所需的值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.