我正在接受有關組合Restlet/Spring的培訓,但有些事情我仍然不明白......我希望你能幫助我。實際上,我正在嘗試使用Spring Restlet的注入依賴系統(如本教程中所示:http://restlet.com/technical-resources/restlet-framework/guide/2.3/introduction/getting-started/maven-spring)。所以我試圖自己做,但沒有奏效。我的代碼返回此異常:Q - Restlet/Spring - NotWritablePropertyException與教程示例?
org.springframework.beans.factory.BeanCreationException:錯誤創建名稱爲豆「basecampComponent」在ServletContext的資源定義[/WEB-INF/applicationContext.xml的]: 無法解析參考bean'basecampAppliction',同時設置bean屬性'defaultTarget';嵌套的異常是org.springframework.beans.factory.BeanCreationException:在ServletContext資源[/WEB-INF/applicationContext.xml]中定義名稱爲'basecampAppliction'的bean時出錯: 設置屬性值時出錯;嵌套異常是org.springframework.beans.NotWritablePropertyException:豆類的無效的屬性「根」 [com.mycompany.restlet.basecamp.application.BaseCampApplication]: Bean屬性「根」不可寫或有一個無效的設置方法。 setter的參數類型是否與getter的返回類型相匹配?
所以我一直在尋找的文件「applicationContext.xml中」,這是他的內容:
<bean id="basecampComponent" class="org.restlet.ext.spring.SpringComponent">
<property name="defaultTarget" ref="basecampAppliction" />
</bean>
<bean id="basecampAppliction">class="com.mycompany.restlet.basecamp.application.BaseCampApplication">
<property name="root" ref="router" />
</bean>
<!-- Define the router -->
<bean name="router" class="org.restlet.ext.spring.SpringBeanRouter" />
有人有一個想法,我在那裏可以尋找一種方法來調試呢?
順便說一下,我在Java 1.8.0_60。
感謝您的幫助。 Benjamin
請把'com.mycompany.restlet.basecamp.application.BaseCampApplication'放在你的問題中,或者更確切的說是** root **變量的設置器 – Vihar
'package com.mycompany.restlet.basecamp.application; import org.restlet.Application; import org.restlet.ext.spring。SpringBeanRouter; 公共類BaseCampApplication延伸申請{ \t }' 這是基本的代碼。一位朋友告訴我試着在裏面添加這個代碼: 'private SpringBeanRouter root; public void setRoot(SpringBeanRouter route){this.root = route; } public SpringBeanRouter getRoot(){ return this.root; } ' 我試過了,但沒有奏效。 – bconotte
對不起,此演示文稿。我是一個關於在stackoverflow上發佈的新手。 – bconotte