我正在注入构造函数以org.joda.time.DateTime
使用spring作为
<bean id="myDateTime" class="org.joda.time.DateTime">
<constructor-arg type="java.lang.Long" value="${startDateTime:#{null}}" />
</bean>
startDateTime解析为1341571102000
。但是我收到关于无法解析构造函数的错误
Cannot resolve reference to bean 'myDateTime' while setting constructor argument;
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myDateTime' defined in URL [file:/path/to/spring-configuration/application-config.xml]: Could not resolve matching constructor (hint: specify index/type/name arguments for simple parameters to avoid type ambiguities)
本org.joda.time.DateTime
类没有接受一个构造函数java.lang.Long
。您可能想要使用接受原始的那个long
。要做到这一点,尝试指定type="long"
的constructor-arg
。
但是,null
在这种情况下startDateTime
,无法设置为万一的后备状态将不起作用。我不确定这种后备的目的是什么,但是如果要使用long
构造函数,则需要以其他方式解决。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句