![](/img/trans.png)
[英]how to resolve Joda date/time type `org.joda.time.DateTime` not supported by default
[英]Spring bean unable to resolve constructor for org.joda.time.DateTime
我正在使用spring作為org.joda.time.DateTime
構造函數注入
<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
的原始值。 為此,請嘗試為constructor-arg
指定type="long"
。
但是,在未設置startDateTime
情況startDateTime
退為null
的情況將不起作用。 我不確定這種回退的意圖是什么,但是如果要使用long
構造函數,則需要以其他方式解決。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.